contact form
<?php
define("ContactEmail", "highwebgeeta@gmail.com");
$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
$error = false;
$submit = $_POST['submit'];
if (empty($submit))
$form_submitted = false;
else
$form_submitted = true;
if ($form_submitted) {
$title = $_POST['title'];
$name = $_POST['name'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$pin = $_POST['pin'];
$country = $_POST['country'];
$contact = $_POST['contact'];
$email = $_POST['email'];
if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }
if(!$contact) { $error_msg .= "<li>contact</li>"; $error = true; }
if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
$error_msg .= "</ul>";
if (!$error) {
$msg = "Full Name: \t $name \n";
$msg .= "Contact: \t $contact \n";
$msg .= "E-mail Address: \t $email \n";
$msg .= "address: \n---\n $address \n---\n";
$mailheaders = "Enquiry";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $name <$email>\r\n";
mail(ContactEmail, $subject , stripslashes($msg), $mailheaders);
}
}
?>
<?php
// email was successfully send
if (($form_submitted) && (!$error)) {
?>
<!-- display submitted data -->
Thank you for your feedback, <?php echo $name; ?>.
This is the information you submitted:<?php echo nl2br(stripslashes($msg)); ?>
i create a contact form that link to 5 pages , please help me to create a contact form using php..
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
i create a contact form that link to 5 pages , please help me to create a contact form using php..
Well what seems to be the problem. Does it not function properly or are the errors reported. If so, what are the errors reported.
Also I noticed your mail function is incorrect and needs to be as follows:
mail("ContactEmail", $subject , stripslashes($msg), $mailheaders);
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Parse error: syntax error, unexpected $end in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 61
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
Parse error: syntax error, unexpected $end in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 61
this error occurs...
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
<?php
define("ContactEmail", "your-email");
$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
$error = false;
$submit = $_POST['submit'];
if (empty($submit))
$form_submitted = false;
else
$form_submitted = true;
if ($form_submitted) {
$title = $_POST['title'];
$name = $_POST['name'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$pin = $_POST['pin'];
$country = $_POST['country'];
$contact = $_POST['contact'];
$email = $_POST['email'];
if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }
if(!$contact) { $error_msg .= "<li>contact</li>"; $error = true; }
if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
$error_msg .= "</ul>";
if (!$error) {
$msg = "Full Name: \t $name \n";
$msg .= "Contact: \t $contact \n";
$msg .= "E-mail Address: \t $email \n";
$msg .= "address: \n---\n $address \n---\n";
$mailheaders = "Enquiry";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $name <$email>\r\n";
mail("your-email", $subject , stripslashes($msg), $mailheaders);
}
?>
<?php
// email was successfully send
if (($form_submitted) && (!$error)) {
?>
<!-- display submitted data -->
Thank you for your feedback, <?php echo $name; ?>.
This is the information you submitted:<?php echo nl2br(stripslashes($msg)); ?>
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
I just checked you script for what line is 61 and your script only goes to line 52. Could you post from lines 50 to 62 so I can see what needs fixing?
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
<?php
define("ContactEmail", "highwebgeeta@gmail.com");
$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
$error = false;
$submit = $_POST['submit'];
if (empty($submit))
$form_submitted = false;
else
$form_submitted = true;
if ($form_submitted) {
$title = $_POST['title'];
$name = $_POST['name'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$pin = $_POST['pin'];
$country = $_POST['country'];
$contact = $_POST['contact'];
$email = $_POST['email'];
if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }
if(!$contact) { $error_msg .= "<li>contact</li>"; $error = true; }
if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
$error_msg .= "</ul>";
if (!$error) {
$msg = "Full Name: \t $name \n";
$msg .= "Contact: \t $contact \n";
$msg .= "E-mail Address: \t $email \n";
$msg .= "address: \n---\n $address \n---\n";
$mailheaders = "Enquiry";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $name <$email>\r\n";
mail("highwebgeeta@gmail.com", $subject , stripslashes($msg), $mailheaders);
}
?>
<?php
// email was successfully send
if (($form_submitted) && (!$error)) {
?>
<!-- display submitted data -->
Thank you for your feedback, <?php echo $name; ?>.
This is the information you submitted:<?php echo nl2br(stripslashes($msg));
?>
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
Hi ..
you have to close one if condition at last..
}
i did bt nothing happened.. same error
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
FOUND IT (i think)
Try making the following your code as you missed the last closing bracket on the last line.
<?php
define("ContactEmail", "highwebgeeta@gmail.com");
$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
$error = false;
$submit = $_POST['submit'];
if (empty($submit))
$form_submitted = false;
else
$form_submitted = true;
if ($form_submitted) {
$title = $_POST['title'];
$name = $_POST['name'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$pin = $_POST['pin'];
$country = $_POST['country'];
$contact = $_POST['contact'];
$email = $_POST['email'];
if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }
if(!$contact) { $error_msg .= "<li>contact</li>"; $error = true; }
if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
$error_msg .= "</ul>";
if (!$error) {
$msg = "Full Name: \t $name \n";
$msg .= "Contact: \t $contact \n";
$msg .= "E-mail Address: \t $email \n";
$msg .= "address: \n---\n $address \n---\n";
$mailheaders = "Enquiry";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $name <$email>\r\n";
mail("highwebgeeta@gmail.com", $subject , stripslashes($msg), $mailheaders);
}
?>
<?php
// email was successfully send
if (($form_submitted) && (!$error)) {
?>
<!-- display submitted data -->
Thank you for your feedback, <?php echo $name; ?>.
This is the information you submitted:<?php echo nl2br(stripslashes($msg));
} ?>
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Parse error: syntax error, unexpected $end in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 121
i cahnged my code to ur code showing the above error....:-(
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
Parse error: syntax error, unexpected $end in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 60
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
can u send me contact form script?
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
hey i tried this now showing this error
Notice: Undefined index: submit in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 14
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
hey i tried this now showing this error
Notice: Undefined index: submit in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\requirements-form\mail.php on line 14
rohnni
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 6
Solved Threads: 0
FYI, Notice is not an error and can be turned off with different Error reporting values..
Edit: It is kind of an error, but can be ignored. (Doh!)
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356