nagger Posted September 27, 2007 Share Posted September 27, 2007 Guys, Just trying to get into PHP but I am struggling with the following: When setting up a php mail form I can get all working. My problem is that I can't get the form to send both the fillers name and email and display it in the body of the received email. In the HTML age I have <form action="process.php" method="post"> Name: <input type="text" name="name" size="20" maxlength="20" /><br /> Email: <input type="text" name="email" size="30" maxlength="30" /><br /> <input type="hidden" name="sub" value="XXXXX" /><br /> <input type="submit" name="submit" value="Send" /> </form> And in the php page I have Thanks <?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); mail('[email protected]',$sub,$email,"From: $name <$email>"); echo $_POST["name"]; ?> , We will drop you a line shortly. Any thoughts? Link to comment https://forums.phpfreaks.com/topic/70879-entry-level-problem/ Share on other sites More sharing options...
apulmca2k4 Posted October 17, 2008 Share Posted October 17, 2008 Yes, I can do it. contact on [email protected] Link to comment https://forums.phpfreaks.com/topic/70879-entry-level-problem/#findComment-667754 Share on other sites More sharing options...
kenrbnsn Posted October 17, 2008 Share Posted October 17, 2008 This forum is for help for everyone's benefit. If you have a solution post it here. Ken Link to comment https://forums.phpfreaks.com/topic/70879-entry-level-problem/#findComment-667756 Share on other sites More sharing options...
o3d Posted October 17, 2008 Share Posted October 17, 2008 you can try this: <?PHP if (isset($_POST['submit'])) { $name = ""; $email = ""; if (isset($_POST['name'])) $name = $_POST['name']; if (isset($_POST['email'])) $email = $_POST['email']; $Body .= "Name: $name\n"; $Body .= "Email: $email\n"; if (mail('[email protected]','Mail from website',$Body,"From: $email")) echo 'mail has been sent<br>'; else echo 'mail could not be sent<br>'; } ?> <form method="POST"> Name: <input type="text" name="name" size="20" maxlength="20" /><br /> Email: <input type="text" name="email" size="30" maxlength="30" /><br /> <input type="submit" name="submit" value="Send" /> </form> Link to comment https://forums.phpfreaks.com/topic/70879-entry-level-problem/#findComment-667782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.