Simple php contact form that is submitting blank responses

I’ll keep it simple - I can do css / html but I know nothing about php. This form “replies” to requests successfully, but leaves the fields blank - it works perfectly on another host, but not the one I’m dealing with now… Any ideas what’s missing?

HTML Code:

Request a Callback

Name

Telephone Number

PHP Code:

<?php if(isset($_POST['name'])) { $email_to = "[email protected]"; $email_subject = "Contact from Fizz Web Design"; // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['telephonenumber'])) $name = $_POST['name']; // required $telephone_number = $_POST['telephonenumber']; // required $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Telephone Number: ".clean_string($telephonenumber)."\n"; // create email headers $headers = 'From: Fizz Web Design'. //'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <?php } ?>

HTML Code:

[php]

Request a Callback

Name

Telephone Number

[/php]

PHP Code:

[php]<?php
if(isset($_POST[‘submit’])) {

$name = $_POST['name']; // required
$telephone_number = $_POST['telephonenumber']; // required
 
if(!isset($_POST['name']) ||
    !isset($_POST['telephonenumber'])){
	
	/*Enter your
 * validation code
 * HERE!
 * */

}

else{
	$email_to = "[email protected]";
	$email_subject = "Contact from Fizz Web Design";
	$email_message = "Form details below.\n\n";
 
function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}

$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Telephone Number: ".clean_string($telephone_number)."\n";

// create email headers
$headers = ‘From: Fizz Web Design’.
//'Reply-To: '.$email_from."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
}
?>
[/php]

Thanks for this, but I’m now not even receiving the unfilled in email responses with these changes?

ok ok I’ve been dumb - responses were hitting my spam folder all of a sudden - seems to be working fine now - I’m not sure what the problem was with the original code though if you have the time to give a hint or two?

But thanks for the response. Appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service