Copy link to clipboard
Copied
Hi All,
Admittedly, I know nothing about PHP. Trying to get a simple contact form to work has been a frustrating process.
Below is the PHP that I am using. When the contact form is received, all the info is on one line, strung together without line breaks. I'm wondering how to add breaks to the submitted email.
Your help is greatly appreciated. Thank you.
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$message = $_REQUEST['message'] ;
mail( "name@anysite.com", "Feedback Form Results",
$name.=$phone.$message ; "From: $email" );
header( "Location: http://www.anysite.com/thankyou.html" ) ;
?>
Copy link to clipboard
Copied
Couple of things to note,
You should have a ","not a ";" separating the message and headers fields.
Secondly, "$name.=$phone.$message" is meaningless. If you are trying to concatenate the three fields together, you have to use "." and add in whatever spaces of carriage returns/linefeeds you want. So:
$name."<br>".$phone."<br>".$message
It's frequently good to add labels to the fields so the reader knows what sorts of information should be there.
The text in any line should not exceed70 characters, according to the PHP rules. You will have to break up the message if it's longer than that.
Unless you are doing a lot of error checking for bad input, you are exposing yourself to a lot of harm using this function, like opening you and your server up to all sorts of nasty attacks.
Never trust any input from the user.