PHP Code for form

I have made a rather simple form for my website consisting of two text boxes and a drop down list containing two choices. I have set up a .php file to have an email sent to me with the entered data. I am able to receive the email with the data for the two text boxes, but I can’t figure out the script to display the list choice. I am very very new to all of this, so I hope I have described my problem effectively.

Here is the form, and below the .php script I am having problem with.


Email address:
Exchange Type: Basic Premium

$headersep = (!isset( $uself ) || ($uself == 0)) ? “rn” : “n” ;
$name = $_POST[‘name’] ;
$email = $_POST[‘email’] ;
$comments = $_POST[‘select’] ;
$http_referrer = getenv( “HTTP_REFERER” );

if (!isset($_POST[‘email’])) {
header( “Location: $formurl” );
exit ;
if (empty($name) || empty($email)) {
header( “Location: $errorurl” );
exit ;
if ( ereg( “[rn]”, $name ) || ereg( “[rn]”, $email ) ) {
header( “Location: $errorurl” );
exit ;


$messageproper =

"This message was sent from:n" .
"$http_referrern" .
"------------------------------------------------------------n" .
"Name of sender: $namen" .
"Email of sender: $emailn" .
"Type: $selectn" .
"nn------------------------------------------------------------n" ;

mail($mailto, $subject, $messageproper,
“From: “$name” <$email>” . $headersep . “Reply-To: “$name” <$email>” . $headersep . “X-Mailer: chlinkus.php 2.08” );
header( “Location: $thankyouurl” );
exit ;

Admin Edit: Added Missing end CODE tag

I am not sure exactly what you are asking. Are you trying to see how your “Choices” of Premium and Basic are to be coded?

That does appear to be coded ok (If that is the question).

Another thing I noticed, however, is the lack of the <?php and ?> tags around the relevant sections of code.

when i receive the email, the choice basic or premium doesn’t appear. I only get the name and the email address.

change the following line:

// See comments to right of line
$comments = $_POST[‘select’] ; // <---- Wrong
$select = $_POST[‘select’] ; // <------ Right


It’s not that it’s wrong, it’ just not consistent with the rest of the code.

thank you, that little oversight seemed to be the problem.

Sponsor our Newsletter | Privacy Policy | Terms of Service