Jump to content

PHP Email ~ Message New Line Question


Recommended Posts

Hello, this is the first post I am making on this forum, so print("hello world!"); I am working on a mail system for my free hosting account over at 000webhost, and I need the email to be split into sections, where I have each line of data, ex. Name, Email, Subject, all on a separate line. Here is my code, and I will blank out the email I will be using for the form. I tried using \n to make a new line, but that didn't work. So if anyone can help, that would be great.

<html><body><?php/* This code here will mail off an email from the webform to ... *//* These are the fields of the form. The ones with * need to be filled out.nameemail *subject *message *check **/$name=$_POST["name"];$email=$_POST["email"];$subject=$_POST["subject"];$message=$_POST["message"];$check=$_POST["check"];$sendemailto="..."; // Who to send the email toprint $name;print $email;print $subject;print $message;print $check;if ($email=="" or $subject=="" or $message=="" or $check==""){ // If any of these fields are equal to nothing, thenprint "You have missed some fields. Go back and fill out all of the fields that have a * next to them.";}elseif ($email!="" and $subject!="" and $message!="" and $check==...){$message = "Name: " . $name "\n Email: " . $email "\n Subject: " . $subject "\n Message: " . $message ;$headers = "From:" . $email;mail($sendemailto,$subject,$message,$headers);print "Email sent!";}?></body></html>

Edited by AKSoapy29
Link to comment
Share on other sites

Welcome to the forums. Looks like you're missing some concatenation operators here:

$message = "Name: " . $name "\n Email: " . $email "\n Subject: " . $subject "\n Message: " . $message ;

Try this:

$message = "Name: " . $name . "\n Email: " .  $email . "\n Subject: " .  $subject .  "\n Message: " .  $message ;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...