Hi,
I admit I am a novice with php right now. My problem is with this php code that I copied from a tuitorial, and I keep getting back "You have not entered an email, please go back and try again."
I'm hoping someone would help me and I would also like to send them a successful page a thank you page too.
Regards,
Lee Frandsen posting.php?mode=post&f=1#
<style type="text/css">
#recaptcha_error_box {
width:30%;
border:medium groove #A00;
background-color:#FF9;
padding:1em;
color:#900;
font-weight:bold;
font-size:80%;}
</style>
<?php
require_once('recaptchalib.php');
$privatekey = "xxxxx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo '<div id="recaptcha_error_box">The reCAPTCHA failed with this message: '.$response->error.'<br />Please try again.</div>';
} else
{
$to = $_POST['leefrand@cox.net'];
$name = $_POST['name'];
$from = $_POST['email'];
$headers = "from: $from";
$subject = "estimateform";
$fields = array();
$fields{"name"} = "name";
$fields{"phone"} = "phone";
$fields{"businesstype"} = "businesstype";
$fields{"email"} = "email";
$fields{"company"} = "company";
$fields{"designcheck"} = "designcheck";
$fields{"pages"} = "pages";
$fields{"forms"} = "forms";
$fields{"optimize"} = "optimize";
$fields{"presentsite"} = "presentsite";
$fields{"admire"} = "admire";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b)
{$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@leedoeswebsites.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else
{
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);}
}
}
?>
emailing html form with php
Moderator: General Moderators
Re: emailing html form with php
Without the full code (mainly the actual form) kinda hard to tell. Perhaps you have the input named differently?
If you want an example of a full working contact form my reply on this post: viewtopic.php?f=1&t=130159&p=654640#p654640
If you want an example of a full working contact form my reply on this post: viewtopic.php?f=1&t=130159&p=654640#p654640
Re: emailing html form with php
Thanks for the reply. I'd like to do my forms in html 'till I am better at php. Here is my html form code:
<form action="http://www.fatcow.com/scripts/formemail.bml" method="post" name="estimateform" onsubmit="return validate()">
<h2>FCS Estimate Form</h2>
<br>
<table width="500" border="0" cellspacing="5" cellpadding="0">
<tr>
<td><font color="red">*</font>Full Name:</td>
<td><input type="text" name="name" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font> Phone Number:</td>
<td align="left" width="50%"><input type="text" name="phone" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font>Business Type:</td>
<td align="left" width="50%"><input id="businessype" type="text" name="businesstype" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font>email Address:</td>
<td align="left" width="50%"><input id="email" type="text" name="email" value="" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">Company Name</td>
<td align="left" width="50%"><input type="text" name="company" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">New Design?</td>
<td align="left" width="50%"><input type="checkbox" name="designcheck" value="yes">Yes<input type="checkbox" name="designcheck" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Est. Number of Pages</td>
<td align="left" width="50%"><input type="text" name="pages" size="3"></td>
</tr>
<tr>
<td align="left" width="50%">Do you need Forms?</td>
<td align="left" width="50%"><input type="checkbox" name="forms" value="yes">Yes<input type="checkbox" name="Forms" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Search Engine Optimization?</td>
<td align="left" width="50%"><input type="checkbox" name="optimize" value="yes">Yes<input type="checkbox" name="optimize" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Your Present Website URL</td>
<td align="left" width="50%"><input type="text" name="presentsite" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">Websites that you Admire<br>
<br>
<font color="red">* = Required field</font></td>
<td align="left" width="50%"><textarea name="admire" rows="4" cols="37"></textarea></td>
</tr>
</table>
<br>
<br>
<input type="hidden" name="my_email" value="leefrand@cox.net"> <input type="hidden" name="required" value="name, phone, businesstype, email"> <input type="hidden" name="thankyou_url" value="http://leedoeswebsites.com/thanks.html"> <input type="hidden" name="order" value="name,phone,businesstype,email,company,designcheck,pages,forms,optimize,presentsite,admire"><br>
<br>
<input type="submit" name="Submit" value="Submit"> <input type="reset">
</form>
<form action="http://www.fatcow.com/scripts/formemail.bml" method="post" name="estimateform" onsubmit="return validate()">
<h2>FCS Estimate Form</h2>
<br>
<table width="500" border="0" cellspacing="5" cellpadding="0">
<tr>
<td><font color="red">*</font>Full Name:</td>
<td><input type="text" name="name" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font> Phone Number:</td>
<td align="left" width="50%"><input type="text" name="phone" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font>Business Type:</td>
<td align="left" width="50%"><input id="businessype" type="text" name="businesstype" size="35"></td>
</tr>
<tr>
<td align="left" width="50%"><font color="red">*</font>email Address:</td>
<td align="left" width="50%"><input id="email" type="text" name="email" value="" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">Company Name</td>
<td align="left" width="50%"><input type="text" name="company" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">New Design?</td>
<td align="left" width="50%"><input type="checkbox" name="designcheck" value="yes">Yes<input type="checkbox" name="designcheck" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Est. Number of Pages</td>
<td align="left" width="50%"><input type="text" name="pages" size="3"></td>
</tr>
<tr>
<td align="left" width="50%">Do you need Forms?</td>
<td align="left" width="50%"><input type="checkbox" name="forms" value="yes">Yes<input type="checkbox" name="Forms" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Search Engine Optimization?</td>
<td align="left" width="50%"><input type="checkbox" name="optimize" value="yes">Yes<input type="checkbox" name="optimize" value="no">No</td>
</tr>
<tr>
<td align="left" width="50%">Your Present Website URL</td>
<td align="left" width="50%"><input type="text" name="presentsite" size="35"></td>
</tr>
<tr>
<td align="left" width="50%">Websites that you Admire<br>
<br>
<font color="red">* = Required field</font></td>
<td align="left" width="50%"><textarea name="admire" rows="4" cols="37"></textarea></td>
</tr>
</table>
<br>
<br>
<input type="hidden" name="my_email" value="leefrand@cox.net"> <input type="hidden" name="required" value="name, phone, businesstype, email"> <input type="hidden" name="thankyou_url" value="http://leedoeswebsites.com/thanks.html"> <input type="hidden" name="order" value="name,phone,businesstype,email,company,designcheck,pages,forms,optimize,presentsite,admire"><br>
<br>
<input type="submit" name="Submit" value="Submit"> <input type="reset">
</form>
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: emailing html form with php
The HTML form code looks ok at first glance. Using the following : print_r($from); in the specific if statement (where the $from variable is checked), what value do you receive?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: emailing html form with php
I've decided to copy the tutorial as is, get it to work, then slowly modify it to my stuff. Thanks for your help.
Lee Frandsen
ps. I may return, but I hope it's not on this same issue.
Lee Frandsen
ps. I may return, but I hope it's not on this same issue.