Jump to content

Not a coder needs help with formatting to send email message


caliray
Go to solution Solved by Barand,

Recommended Posts

I have a bit of php code to send me an email when someone logs in to my site. I want to include the person's name and two other bits from my database, but I can't get the formatting correct. I keep getting errors when I try to load the page. Here's the code which obviously has mistakes. The first code works, it's the second one that does not work for the $message line .

if (mysql_num_rows($exe) == 1) {
		  	$message_m = "Someone with RefCode ".$RefC." has viewed the homepage for the first time.";
			mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m);
		  	setcookie("has_entered_correct_refcode", "true", time()+27000000, "/");
		  	setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/");
		  	header("Location: /index.php");
		  	die();
if (mysql_num_rows($exe) == 1) {
		  	$message_m =" "'.$_POST['fname'].'," with RefCode "'.$RefC.'," and refund amount of "'.$_POST['refvalact'].'," has viewed the homepage.";
			mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m);

		  	setcookie("has_entered_correct_refcode", "true", time()+27000000, "/");
		  	setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/");
		  	header("Location: /index.php");
		  	die();
		  }

Thanks for any help to resolve this.

Link to comment
Share on other sites

Your single quotes and commas need to be inside the double quotes, not outside.

This is a snippet from the code. "'.$_POST['fname'].'," so what do you mean the single quotes and commas need to be inside the double quotes? Could you please write an example so I can see the difference? Thanks.
Link to comment
Share on other sites

 

Precisely that. EG

$message_m ="'" . $_POST['fname'] . "', with RefCode '" . $RefC . "', and .... ";

Alternatively, don't use concatenation if it's confusing you

$message_m = "'{$_POST['fname']}', with RefCode '$RefC', and .... ";

OK, I see what you mean. Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.