Newbie in need of help with a contact form
Posted: Mon Dec 03, 2012 11:21 am
Hi All
I am trying to get a contact form to work, but it doesn't do what the instructions say it should.
I downloaded a ScriptoMart Captcha Contact Form, edited the feedback.php, uploaded all the files. One of the files is a form.php to try out before editing. The form opens up OK, I entered the captcha code, pressed Submit and was directed to a blank page where there should have been a message. The URL ended in feedback.php.
Can one of you switched on guys help?
This is the form php:
And this is the feedback.php:
Thanks.
I am trying to get a contact form to work, but it doesn't do what the instructions say it should.
I downloaded a ScriptoMart Captcha Contact Form, edited the feedback.php, uploaded all the files. One of the files is a form.php to try out before editing. The form opens up OK, I entered the captcha code, pressed Submit and was directed to a blank page where there should have been a message. The URL ended in feedback.php.
Can one of you switched on guys help?
This is the form php:
Code: Select all
<form name="feedback" method="post" action="feedback.php">
<table width="400" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="145"><strong>Name</strong></td>
<td width="443"> <input name="name" type="text" id="name" size="25"></td>
</tr>
<tr>
<td><strong>Email</strong></td>
<td><input name="email" type="text" id="email" size="25"></td>
</tr>
<tr>
<td valign="top"><strong>Company</strong></td>
<td><input name="company" type="text" id="company" size="25"></td>
</tr>
<tr>
<td valign="top"><strong>Comments</strong></td>
<td><textarea name="Comments" cols="40" rows="5" id="Comments"></textarea></td>
</tr>
<tr>
<td> </td>
<td><p><img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" />
<br />
Enter Code:<br />
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="a href="#" onclick="document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random(); return false""><img src="securimage/images/refresh.gif" alt="Click to refresh the verification image" name="verification" width="22" height="20" border="0" id="verification"></a></p></td>
</tr>
<tr>
<td><input type="reset" name="Reset" value="Reset"></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
Code: Select all
<?php session_start(); ?>
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// handle the error accordingly with your other error checking
// or you can do something really basic like this
die('The code you entered was incorrect. Go back and try again.');
}
?>
<?php
# ----------------------------------------------------
# ----- Copyright http://www.scriptomart.com
# ----------------------------------------------------
// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
@$company = addslashes($_POST['company']);
@$Comments = addslashes($_POST['Comments']);
// Validation
// You can add additional form with or without validations below.
// You do not need to validate all form entries.
// The company name only can be left empty on this form submission.
if (strlen($name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>");
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if (strlen($email) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if (strlen($Comments) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid comments</font></p>");
}
// This sends you the feedback form
// Make sure you edit youremail@yourdomain.com to your correct Email Address
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Feedback Form";
$pfw_email_to = "kxxxx@btinternet.com";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "You have received feedback from your online form.\n"
. "\n"
. "The Visitors Name was: $name\n"
. "Their Email Address is: $email\n"
. "Their Company name is: $company\n"
. "The comments they left for you are below:\n"
. " $Comments\n"
. "\n"
. "Check the Date/Time of this email for response time/date.";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//Sending auto respond Email to visitor
// Make sure you edit youremail@yourdomain.com to your correct Email Address
$pfw_header = "From: kxxxx@btinternet.com\n"
. "Reply-To: kxxxx@btinternet.com\n";
$pfw_subject = "Thank you for Contacting us";
$pfw_email_to = "$email";
$pfw_message = "Thank you for your feedback.\n"
. "\n"
. "Should your comments require a response we will do so at the earliest convenient time.\n"
. "\n"
. "Kind Regards\n"
. "\n"
. "Lizzie";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank You, Your submission has been sent!</font></p>");
?>
<script type="text/javascript">
<!-- change the below index.php to the page you would like to redirect after submission
function delayer(){
window.location = "http://www.algethiguesthouse.co.uk/index.htm"
}
//--> to change the delay: 5000 = 5 seconds
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">