i get the full code when i try to run the php in my html file.

i get the full code when i try to run the php in my html file.

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

// here is the email to information
$email_to = "your email goes here";
$email_subject = "This is form your website contact form";
$email_from = "TheTechTalkBlog"

//error code

public function died($error){
	echo "We are sorry, there were error(s) found with the form you submitted.";
	echo "These errors appear below.<br/><br/>";
	echo $error."<br/><br/>";
	echo "Please go back and fix these errors.<br/";
	die();
}

//validation

	if(!isset($_POST['name']) ||
	if(!isset($_POST['email']) ||
	if(!isset($_POST['comments'])){
		died("We are sorry but there appears to be a problem  with the form you submitted");




}

$name = $_POST['name'];
$name = $_POST['email'];
$name = $_POST['comments'];

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp, $email)){
	$error_message .= 'The Email address you entered does not appear to be valid<br/>';
}

$string_exp = "/^[A-Za-z.'-]+$/";
if(!preg_match($string_exp, $name)){
	$error_message .= 'The name you entered does not appear to be valid<br/>'; 
}

if(strlen($comments) < 2){
	$error_message .= 'The comments you entered do no appear to to be valid<br/>';
}

if(strlen($error_message) > 0 ) {
	died($error_message);

}

$email_message = "Form details below. \n\n";

fuction clean_string($string){
	$bad = array("content-type", "bcc:", "to:", "cc:",
		"href";);
}

email_message .= "Name:" . clean_string($name) . "\n";
email_message .= "Email:" . clean_string($name) . "\n";
email_message .= "Comments:" . clean_string($name) . "\n";

//create email headers
$headers = 'From:' .$email_from . "\r\n". 'Reply-To:' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

?>

Thank you for contacting us. We will be in touch with you shortly.

Please click<a href = "home.html"here to go home to the home page.

<?php ?>[/php]

That’s because you can’t run PHP with the .html extension. Change the filename to. PHP. You also have the opening wrong. It should start with <?php

i changed the <? to <?php. after that im lost. sorry im a noob. :’(

Did you rename your file from somefile.htm or somefile.html TO somefile.php like I said?

i have to php file name contact.php and my html file name contact.html.

You can name them all with a .php but the one that MUST be named that way is the ones with php code.

i renamed them. put them both in my WAMP server. I ran the contact.html (now called contact.php) but the submit button does not work. then i ran contact.php and i got the error;( ! ) Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in C:\wamp\www\contact.php on line 11

From your original code post you are missing the closing bracket that is opened here:

if(isset($_POST[‘email’])){

Your missing a semi colon here: $email_from = “TheTechTalkBlog”

The following () are not right.
if(!isset($_POST[‘name’]) ||
if(!isset($_POST[‘email’]) ||
if(!isset($_POST[‘comments’])){

i have updated the code:

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

// here is the email to information
$email_to = "[email protected]";
$email_subject = "This is form your website contact form";
$email_from = "TheTechTalkBlog";

//error code

public function died($error){
	echo "We are sorry, there were error(s) found with the form you submitted.";
	echo "These errors appear below.<br/><br/>";
	echo $error."<br/><br/>";
	echo "Please go back and fix these errors.<br/>";
	die();
}

//validation

if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])){
died("We are sorry but there appears to be a problem  with the form you submitted");
}

$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp, $email)){
	$error_message .= 'The Email address you entered does not appear to be valid<br/>';
}

$string_exp = '/^[A-Za-z.'-]+$/";
if(!preg_match($string_exp, $name)){
	$error_message .= 'The name you entered does not appear to be valid<br/>'; 
}

if(strlen($comments) < 2){
	$error_message .= 'The comments you entered do no appear to to be valid<br/>';
}

if(strlen($error_message) > 0 ) {
	died($error_message);

}

$email_message = "Form details below. \n\n";

fuction clean_string($string){
	$bad = array("content-type", "bcc:", "to:", "cc:",
		"href";);
}

email_message .= "Name:" . clean_string($name) . "\n";
email_message .= "Email:" . clean_string($name) . "\n";
email_message .= "Comments:" . clean_string($name) . "\n";

//create email headers
$headers = 'From:' .$email_from . "\r\n". 'Reply-To:' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

?>

Thank you for contacting us. We will be in touch with you shortly.

Please click<a href = "home.html"here to go home to the home page.

<?php ?>[/php]

Still missing the closing brace I told you about.

iv closed it :

[php]fuction clean_string($string){
$bad = array(“content-type”, “bcc:”, “to:”, “cc:”,
“href”);
}[/php]

wow i cant belive i did that:

[php]fuction clean_string($string){
$bad = array(“content-type”, “bcc:”, “to:”, “cc:”,
“href”);

return str_replace($bad, “”, $string);
}[/php]

That’s not where I told you it was. I’ve given you all the info you need.

everything seems to be fine until i reach line 139

Parse error: syntax error, unexpected ‘clean_string’ (T_STRING) in C:\wamp\www\contact.php on line 139

$string_exp = “’/^[A-Za-z.’-]+$/”;

Sponsor our Newsletter | Privacy Policy | Terms of Service