Jump to content
Killersites Forums

Question About my Php Email form


delirium
 Share

Recommended Posts

Hey there,

 

I have two email forms on http://www.supernerd.ca/contact.php and no matter which one you fill out they both give you the success message in green.

 

They use the same code but with all different variables and stuff. Why is this happening and how to i make it so only the one that is being submitted returns the message..

 

here is the code for both,

 

the one on the left

 

<?

 

$name = $_REQUEST['name'] ;

$email = $_REQUEST['email'] ;

$phone = $_REQUEST['phone'] ;

$adress = $_REQUEST['adress'] ;

$type = $_REQUEST['type'] ;

$service = $_REQUEST['service'] ;

$subject = "Appointment Request From Supernerd.ca" ;

$message = "

 

Name: "."$name"."

Email: "."$email"."

Phone Number: "."$phone"."

Adress: "."$adress"."

Type: "."$type"."

Service: "."$service"."

 

 

 

";

 

if (isset($_REQUEST['email'])) <------ THIS IS WHERE THE ERROR HAPPENS

//if "email" is filled out, send email

{

mail( "pj@supernerd.ca", "$subject",

$message, "From: $email" );

echo "Thanks!, Someone will be in touch with you within 24 hours";

}

else{

?>

Fill out the form bellow to setup an appointment

 

<?

}

?>

 

the one on the right:

 

<?

 

$nameRIGHT = $_REQUEST['nameRIGHT'] ;

$emailRIGHT = $_REQUEST['emailRIGHT'] ;

$mess = $_REQUEST['mess'] ;

$subjectRIGHT = "General contact From Supernerd.ca" ;

$messageRIGHT = "

 

Name: "."$nameRIGHT"."

Email: "."$emaiRIGHT"."

Message: "."$mess"."

 

 

 

";

 

if (isset($_REQUEST['emailRIGHT'])) <----- AND HERE, YET THEY ARE BOTH NAMED DIFFERENT THINGS..???

{

mail( "pj@supernerd.ca", "$subjectRIGHT",

$messageRIGHT, "From: $emailRIGHT" );

echo "Thanks!, Someone will be in touch with you within 24 hours";

}

else{

?>

 

Fill out the form bellow to send us an email

 

<?

}

?>

 

As you see where i have put arrows, the names are completely different yet they BOTH return the success message..

Link to comment
Share on other sites

You need to validate your data differently.

Check to see if the form has been submitted by checking for a 'hidden' form value instead of isset.

Also, you need to throw an error if the form is not completed properly.

In addition, you would be better off not using the REQUEST array. Use POST instead. Look at your form to see which action you are using.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...