ludakriss Posted October 16, 2012 Share Posted October 16, 2012 hi, this is my first post here, i am a php noob. what do i do wrong here? <form method="POST" action="contact.php"> <input type="text" id="email" name="email" size="20" value="E-post" required="required"><br> <input type="text" id="subject" name="subject" size="20" value="Emne" required="required"><br> <input type="text" id="message" name="message" size="20" value="Melding" required="required"><br> <input type="submit" value="Send" name="Submit"> contact.php: <?php $recipient = "my@email.com"; $subject = "$_REQUEST['subject']"; $location = "index.php?id=skjemasendt"; $sender = "$_REQUEST['email']"; $message = $_REQUEST['message']; mail($recipient, $subject, $message, $sender); header( "Location: $location" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/269554-very-simple-formsomthing-is-wrong/ Share on other sites More sharing options...
requinix Posted October 16, 2012 Share Posted October 16, 2012 (edited) what do i do wrong here? Not tell us about the T_ENCAPSED_AND_WHITESPACE error you were getting. If you're just using a variable then don't put it in strings; if you do put one in strings then make sure you do so correctly. And then you'd say something about not getting mail and we'd point out that the fourth argument to mail() needs to be a proper set of headers - not merely the sender's email address. Check the manual page for an example. Or even better, as someone would no doubt point out, would be to use a third-party tool like PHPMailer to send emails because they can handle all the little intricacies that may arise. Possibly overlooked might be that you shouldn't just put the sender's email in that aforementioned list of headers because there's a risk of (email) header injection; another problem that the third-party thing would address. Edited October 16, 2012 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/269554-very-simple-formsomthing-is-wrong/#findComment-1385684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.