Jump to content

Simple PHP contact form not working


gma216

Recommended Posts

I have one form created and posted on 2 seperate servers thats running 2 different versions of php.

 

On this version: http://206studios.com/php.php everything works perfectly fine.

 

but on this version: http://scanwestauto.com/2007/info.php all my variables come up empty.  None of the variables get passed into the email, i just get blanks for all fields inputed on the form.

 

Which properties in the PHP should i be looking for to get the second version working like the first?

 

Any help would be much appreciated.

 

Thanks,

George

Link to comment
https://forums.phpfreaks.com/topic/63387-simple-php-contact-form-not-working/
Share on other sites

The following is the script i used for the contact form, its really straight forward, but for some reason just not working properly on that second version (http://scanwestauto.com/2007/info.php):

 

<?php

 

$to ='[email protected]';

 

$subject ="Scanwest Mailing List Reply";

 

$content="FIRST NAME: $f_name" . "\r\n" . "LAST NAME: $l_name"

 

$mail_from="$email";

 

$header="From: $name <$mail_from>";

 

$send_contact=mail($to,$subject,$content,$header);

 

if($send_contact){

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='."thankYou.html".'">';

}

else {

echo "ERROR";

}

?>

I found an error

 

<?php

$to = '[email protected]'; 

$subject = "Scanwest Mailing List Reply"; 

$content = "FIRST NAME: $f_name" . "\r\n" . "LAST NAME: $l_name";

$mail_from = "$email"; 

$header="From: $name <$mail_from>"; 

$send_contact = mail($to,$subject,$content,$header);

if($send_contact) {
echo '<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=\'.\"thankYou.html\".\'\">';
}
else {
echo "ERROR";
}
?>

Try that. The last bit of code may be wrong, Im not sure. but i fixed the missing ;

The problem with 'blank variables' is caused because your script assumes that register_globals is ON.  That php setting is a potential security problem and OFF is the default setting in recent releases of php.

 

Your form processing script needs to retrieve the passed variables from the array sent by the form.  For example, if your form method is post, then $name = $_POST['name'] will retrieve the variable correctly.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.