Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Hey, I'm trying to make an email form using PHP, but I have one problem. I don't understand how you get the variables from the page with the form, to the page with the actual code to email it. Like, on w3schools, they have this:


<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
 {
 //send email
 $email = $_REQUEST['email'] ;
 $subject = $_REQUEST['subject'] ;
 $message = $_REQUEST['message'] ;
 mail( "someone@example.com", "Subject: $subject",
 $message, "From: $email" );
 echo "Thank you for using our mail form";
 }
else
//if "email" is not filled out, display the form
 {
 echo "<form method='post' action='mailform.php'>
 Email: <input name='email' type='text' /><br />
 Subject: <input name='subject' type='text' /><br />
 Message:<br />
 <textarea name='message' rows='15' cols='40'>
 </textarea><br />
 <input type='submit' />
 </form>";
 }
?>


Where does $_REQUEST come from?



Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
use post variables rather than request variables......





<?php
if (isset($_POST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_POST['email'] ;
$subject = $_POST['subject'] ;
$message = $_POST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>




Last Edit: Aug 29, 2006 0:08:23 GMT by Llanilek

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Thanks a million. It works!


Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

newBookmarkLockedFalling