|
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!
"Behold: me! I have authority in this building."
|
|
|
|
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
|
|
|
|
|