Yes.... another PHP code check!

  ade.h 16:43 20 Jun 2006
Locked

?
$name = $_POST[name] ;
$email = $_POST[email] ;
$location = $_POST[location] ;
$networking = $_POST[networking] ;
$software = $_POST[software] ;
$security = $_POST[security] ;
$message = $_POST[message] ;

if (!isset($_REQUEST[email])) {
header( "Location: click here. URL .com/html/sitefeedback.html" );
}
elseif (empty($name) || empty($email) || empty($message)) {
header( "Location: click here. URL .com/html/error.html" );
}
else {
$mail_message="From: $name";
$mail_message="Location: $location";
$mail_message="Networking: $networking";
$mail_message="Software: $software";
$mail_message="Security: $security";
$mail_message="Message: $message";
mail( "me @ URL .com", "Form Message",
$mail_message, "From: $name $email>" );
header( "Location: click here. URL .com/html/success.html" );
}
?>

(Note: the first chevron and the double space before each line are in the original code, but may not display here)

This code works insofar as I get the message body from anyone who sends me feedback or a site submission. The name/email header works as well. But the other info (the mail_message bits) get lost. I ideally need these to know which section of the site they are referring to. The networking, software and security fields are checkboxes, if that makes any difference.

I must have put them in the wrong place, or not phrased them right, but I have searched a few PHP sites and this layout seems to be correct.

Where have I gone wrong? Should the mail_message bits be part of the header or something?

  harristweed 11:26 21 Jun 2006

The reason the bits get lost is because they over write each other...

The variable $mail_message

Is set as $mail_message="From: $name";

Then it is set as $mail_message="Location: $location";

Therefore it is now Locaton and the name has been lost.

You need to join the message variable new bits onto the existing bits.

So alter the code to:
$mail_message.="From: $name";
$mail_message.="Location: $location";

See the dot?

That will concatenate (i think thats how it's spelt) the variable, and it should work properly.

It is also a good idea to put a line break in. Makes the email easier to read. i.e.
$mail_message.="From: $name

";
$mail_message.="Location: $location

";

etc

  ade.h 16:56 21 Jun 2006

Thanks again! Concatentation; I see what you mean (and don't worry, you spelt it right!) I'm learning new things about PHP every day.

I tried the spacing recently, but it didn't work for me (may be a server thing?) but I read about the \n command that you add to each line, so I'll probably try that.

Thanks for your help.

  ade.h 16:57 21 Jun 2006

Or concatentation even. No extra t. LOL.

  ade.h 16:58 21 Jun 2006

Ah, never mind...

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

50 best online Adobe XD tutorials

iPad Pro 10.5in (2017) review

Comment connecter un MacBook à une TV ?