tinfanide Posted November 19, 2011 Share Posted November 19, 2011 <?php$name = $_POST['name'];$email = $_POST['email'];$website = $_POST['website'];$message = $_POST['message'];$subject = "testing PHP 121";$headers = "Sender: ".$name." His\/Her website: ".$website;mail($email,$subject,stripslashes($message),$headers);?> <form id="contacts-form" method="post" action="mail_sent.php" target="_blank"> <fieldset> <div class="field"><label>Your Name:</label><input type="text" name="name" value=""/></div> <div class="field"><label>Your E-mail:</label><input type="text" name="email" value=""/></div> <div class="field"><label>Your Website:</label><input type="text" name="website" value=""/></div> <div class="field"><label>Your Message:</label><textarea cols="1" name="message" rows="1"></textarea></div> </fieldset> <input type="button" value="Submit" onclick="submitForm('contacts-form')" /> </form> <script> function submitForm(){ document.getElementById("contacts-form").submit(); } </script> I've tried many PHP String methods like stripslashes() but seem to fail to escape the slashes in $headers = "Sender: ".$name." His\/Her website: ".$website; I used "\" to escape the "/" but failed. Link to comment Share on other sites More sharing options...
westman Posted November 19, 2011 Share Posted November 19, 2011 <?php$name = $_POST['name'];$email = $_POST['email'];$message = $_POST['message'];$name = stripslashes($name);$name = strip_tags($name);$email = stripslashes($email);$email = strip_tags($email);$message = stripslashes($message);$message = strip_tags($message);// Start assembly of Email$to = "$email";// Change this to your site admin email$from = "info@admin.com";$subject = "testing PHP 121";$headers = "From: $from\r\n";$headers .= "Content-type: text/html\r\n";$to = "$email";// Finally send the emailmail($to, $subject, $message, $headers);?>hope this works for you. Link to comment Share on other sites More sharing options...
Ingolme Posted November 19, 2011 Share Posted November 19, 2011 I don't think / needs to be escaped, which would explain why that failed. Link to comment Share on other sites More sharing options...
tinfanide Posted November 19, 2011 Author Share Posted November 19, 2011 <?php$sender = $_POST['sender'];$email = $_POST['email'];$website = $_POST['website'];$message = $_POST['message'];$subject = "testing PHP 123";$headers = "At $website\r\n";$headers .= "From: Tin";mail($email,$subject,stripslashes($message),$headers);?> I've adapted from the sample but still cannot get the first hearders $headers = "From: $name\r\n"; Please have a test if you like:Go to:http://lifelearning.mywebcommunity.org/submitForm-test/contact-us.html Have a look at the headers variable in the PHP. It only shows the website, not the "From Tin" Link to comment Share on other sites More sharing options...
justsomeguy Posted November 21, 2011 Share Posted November 21, 2011 The from header needs to be a valid email address or email/name combination according to RFC 2822. It's not just whatever text you want to put there. Check the examples on the manual page for the to address, the from address follows the same rules. http://www.php.net/manual/en/function.mail.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.