html form
Posted: Sat Apr 03, 2004 6:04 pm
hi all,
first time here no php experience.
i was asked to look at why this form was not giving the data as it should the owner of the site was playing with the form makin alterations can somebody look at the code and see where he is going wrong?
there are 2 booking forms enquiry.html and the enquiry.php version.
can someone tell me, do you do the form in html then call the action to an identical page with the php data base is that right?
i think it had something to do with variables not matching text boxes is that right?
any help and or help to recostruct the form would be great.
thanks,
kevin
here are both form scripts:
enquire.html form
<form name="contact" method="post" action="enquire.php">
<h1>Enquire or book online</h1>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="167">Name: </td>
<td width="262">
<input type="text" name="name" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td rowspan="2" width="196"><font size="-1"><font color="#FF0066"><b>*</b></font></font>
indicates a required field</td>
</tr>
<tr>
<td width="167">Phone:</td>
<td width="262">
<input type="text" name="phone" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
</tr>
<tr>
<td width="167">Mobile:</td>
<td width="262">
<input type="text" name="fax" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Email:</td>
<td width="262">
<input type="text" name="email" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of Rooms:</td>
<td width="262">
<input type="text" name="street" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of guests:</td>
<td width="262">
<input type="text" name="town" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of nights:</td>
<td width="262">
<input type="text" name="state" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Arrival date:</td>
<td width="262">
<input type="text" name="postcode" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Add'l requests:</td>
<td width="262">
<input type="text" name="country" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Preferred contact method:</td>
<td width="262">
<input type="radio" name="replymethod" value="email" checked>
<font size="-1">email </font>
<input type="radio" name="replymethod" value="phone">
<font size="-1">phone call
<input type="radio" name="replymethod" value="fax">
fax</font></td>
<td width="196"> </td>
</tr>
<tr>
<td nowrap height="28"><label for="replymethod"><font size="-1"></font></label></td>
<td nowrap height="28">
<input type="submit" name="submit" value="submit">
<input type="reset" name="clear" value="clear">
</td>
<td width="196" height="28"> </td>
</tr>
<tr>
<td width="167"> </td>
<td width="262"> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167"> </td>
<td width="262"> </td>
<td width="196"> </td>
</tr>
</table>
<p>The homestead is a non-smoking area.</p>
<p>A 50% deposit is required to confirm your reservation. If you cancel
and we are able to re-let the suite, we will refund your deposit, less
10% administrative fee. If we are unable to re-let, we will send you
a non-transferable voucher to the value of the deposit paid.</p>
<p align="right"><font size="-2">Site design, maintenance & hosting
by:<br>
</font><a href="http://www.metamorph.com.au" target="_blank"><img src="images/metamorph.jpg" width="135" height="32" border="0"></a></p>
</form>
________________________________________________________
PHP
enquire.php
<?php
if (($name == "") or ($phone == "") or ($email == "") or ($town == "") or ($state == "") or ($country == ""))
{
print "<form name=\"contact\" method=\"post\" action=\"$PHP_SELF\">
<h1>Enquire or book online</h1>
<p>You have not completed all required fields, please complete at least all fields marked with <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>.</p>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">
<tr>
<td width=\"157\">Name: </td>
<td width=\"217\"> <input type=\"text\" name=\"name\" value=\"$name\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td rowspan=\"2\" width=\"116\"><font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
indicates a required field</td>
</tr>
<tr>
<td width=\"157\">Phone:</td>
<td width=\"217\"> <input type=\"text\" name=\"phone\" value=\"$phone\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
</tr>
<tr>
<td width=\"157\">Fax:</td>
<td width=\"217\"> <input type=\"text\" name=\"fax\" value=\"$fax\" size=\"20\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Email:</td>
<td width=\"217\"> <input type=\"text\" name=\"email\" value=\"$email\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Street address:</td>
<td width=\"217\"> <input type=\"text\" name=\"street\" value=\"$street\" size=\"20\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Town/Suburb/City:</td>
<td width=\"217\"> <input type=\"text\" name=\"town\" value=\"$town\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">State:</td>
<td width=\"217\"> <input type=\"text\" name=\"state\" value=\"$state\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Postcode:</td>
<td width=\"217\"> <input type=\"text\" name=\"postcode\" value=\"$postcode\" size=\"6\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Country<font size=\"-1\"><font color=\"#FF0066\"></font></font>:</td>
<td width=\"217\"> <input type=\"text\" name=\"country\" value=\"$country\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Preferred contact method:</td>
<td width=\"217\"> <input type=\"radio\" name=\"replymethod\" value=\"email\" checked>
<font size=\"-1\">email </font> <input type=\"radio\" name=\"replymethod\" value=\"phone\">
<font size=\"-1\">phone call
<input type=\"radio\" name=\"replymethod\" value=\"fax\">
fax</font></td>
<td width=\"116\"> </td>
</tr>
<tr>
<td nowrap height=\"28\"><label for=\"replymethod\"><font size=\"-1\"></font></label></td>
<td nowrap height=\"28\"> <input type=\"submit\" name=\"submit\" value=\"submit\">
<input type=\"reset\" name=\"clear\" value=\"clear\"> </td>
<td width=\"116\" height=\"28\"> </td>
</tr>
</table>
<p>The homestead is a non-smoking area.</p>
<p>A 50% deposit is required to confirm your reservation. If you cancel
and we are able to re-let the suite, we will refund your deposit, less
10% administrative fee. If we are unable to re-let, we will send you
a non-transferable voucher to the value of the deposit paid.</p>
</form>
";
}
else
{
// get day, date and time of form submission
$sub_time = date("D F d Y H:i:s.");
// mail form data to info@ginninderry.com.au
mail("info@ginninderry.com.au", "Online enquiry",
"Please contact the following potential client following an online enquiry\n
--------------------------------------------------------------\n
Name: $name\n
Phone: $phone\n
Fax: $fax\n
Email address: $email\n
Street address: $steet\n
Town/Suburb: $town\n
State: $state\n
Postcode: $postcode\n
Country: $country\n
Preferred reply method: $replymethod\n
---------------------------------------------------------------\n
User information\n
Client name and version: $HTTP_USER_AGENT\n
Clients IP address: $REMOTE_ADDR\n
Refering page: $HTTP_REFERER\n
---------------------------------------------------------------\n
Submission date and time: $sub_time\n
\n", "From: web@ginninderry.com.au\nReply-To: info@ginninderry.com.au\nX-Mailer: PHP/");
print "<h1>Thank you $name for your enquiry</h1>
<p>Ginninderry Homestead will respond by $replymethod to your enquiry shortly.</p>";
}
?>
so if i add the the extra text boxes at the top where the if (($name == "") or ($phone == "") or code is all should be right is that right?
hope you are still around would like some help as i'd like to help these people out i may just land them as clients.
they had issues with their designer and have made some chages themselves and things have not gone as they would of liked.
first time here no php experience.
i was asked to look at why this form was not giving the data as it should the owner of the site was playing with the form makin alterations can somebody look at the code and see where he is going wrong?
there are 2 booking forms enquiry.html and the enquiry.php version.
can someone tell me, do you do the form in html then call the action to an identical page with the php data base is that right?
i think it had something to do with variables not matching text boxes is that right?
any help and or help to recostruct the form would be great.
thanks,
kevin
here are both form scripts:
enquire.html form
<form name="contact" method="post" action="enquire.php">
<h1>Enquire or book online</h1>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="167">Name: </td>
<td width="262">
<input type="text" name="name" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td rowspan="2" width="196"><font size="-1"><font color="#FF0066"><b>*</b></font></font>
indicates a required field</td>
</tr>
<tr>
<td width="167">Phone:</td>
<td width="262">
<input type="text" name="phone" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
</tr>
<tr>
<td width="167">Mobile:</td>
<td width="262">
<input type="text" name="fax" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Email:</td>
<td width="262">
<input type="text" name="email" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of Rooms:</td>
<td width="262">
<input type="text" name="street" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of guests:</td>
<td width="262">
<input type="text" name="town" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">No of nights:</td>
<td width="262">
<input type="text" name="state" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Arrival date:</td>
<td width="262">
<input type="text" name="postcode" size="20">
</td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Add'l requests:</td>
<td width="262">
<input type="text" name="country" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167">Preferred contact method:</td>
<td width="262">
<input type="radio" name="replymethod" value="email" checked>
<font size="-1">email </font>
<input type="radio" name="replymethod" value="phone">
<font size="-1">phone call
<input type="radio" name="replymethod" value="fax">
fax</font></td>
<td width="196"> </td>
</tr>
<tr>
<td nowrap height="28"><label for="replymethod"><font size="-1"></font></label></td>
<td nowrap height="28">
<input type="submit" name="submit" value="submit">
<input type="reset" name="clear" value="clear">
</td>
<td width="196" height="28"> </td>
</tr>
<tr>
<td width="167"> </td>
<td width="262"> </td>
<td width="196"> </td>
</tr>
<tr>
<td width="167"> </td>
<td width="262"> </td>
<td width="196"> </td>
</tr>
</table>
<p>The homestead is a non-smoking area.</p>
<p>A 50% deposit is required to confirm your reservation. If you cancel
and we are able to re-let the suite, we will refund your deposit, less
10% administrative fee. If we are unable to re-let, we will send you
a non-transferable voucher to the value of the deposit paid.</p>
<p align="right"><font size="-2">Site design, maintenance & hosting
by:<br>
</font><a href="http://www.metamorph.com.au" target="_blank"><img src="images/metamorph.jpg" width="135" height="32" border="0"></a></p>
</form>
________________________________________________________
PHP
enquire.php
<?php
if (($name == "") or ($phone == "") or ($email == "") or ($town == "") or ($state == "") or ($country == ""))
{
print "<form name=\"contact\" method=\"post\" action=\"$PHP_SELF\">
<h1>Enquire or book online</h1>
<p>You have not completed all required fields, please complete at least all fields marked with <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>.</p>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">
<tr>
<td width=\"157\">Name: </td>
<td width=\"217\"> <input type=\"text\" name=\"name\" value=\"$name\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td rowspan=\"2\" width=\"116\"><font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
indicates a required field</td>
</tr>
<tr>
<td width=\"157\">Phone:</td>
<td width=\"217\"> <input type=\"text\" name=\"phone\" value=\"$phone\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
</tr>
<tr>
<td width=\"157\">Fax:</td>
<td width=\"217\"> <input type=\"text\" name=\"fax\" value=\"$fax\" size=\"20\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Email:</td>
<td width=\"217\"> <input type=\"text\" name=\"email\" value=\"$email\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Street address:</td>
<td width=\"217\"> <input type=\"text\" name=\"street\" value=\"$street\" size=\"20\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Town/Suburb/City:</td>
<td width=\"217\"> <input type=\"text\" name=\"town\" value=\"$town\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">State:</td>
<td width=\"217\"> <input type=\"text\" name=\"state\" value=\"$state\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Postcode:</td>
<td width=\"217\"> <input type=\"text\" name=\"postcode\" value=\"$postcode\" size=\"6\"> </td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Country<font size=\"-1\"><font color=\"#FF0066\"></font></font>:</td>
<td width=\"217\"> <input type=\"text\" name=\"country\" value=\"$country\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\"> </td>
</tr>
<tr>
<td width=\"157\">Preferred contact method:</td>
<td width=\"217\"> <input type=\"radio\" name=\"replymethod\" value=\"email\" checked>
<font size=\"-1\">email </font> <input type=\"radio\" name=\"replymethod\" value=\"phone\">
<font size=\"-1\">phone call
<input type=\"radio\" name=\"replymethod\" value=\"fax\">
fax</font></td>
<td width=\"116\"> </td>
</tr>
<tr>
<td nowrap height=\"28\"><label for=\"replymethod\"><font size=\"-1\"></font></label></td>
<td nowrap height=\"28\"> <input type=\"submit\" name=\"submit\" value=\"submit\">
<input type=\"reset\" name=\"clear\" value=\"clear\"> </td>
<td width=\"116\" height=\"28\"> </td>
</tr>
</table>
<p>The homestead is a non-smoking area.</p>
<p>A 50% deposit is required to confirm your reservation. If you cancel
and we are able to re-let the suite, we will refund your deposit, less
10% administrative fee. If we are unable to re-let, we will send you
a non-transferable voucher to the value of the deposit paid.</p>
</form>
";
}
else
{
// get day, date and time of form submission
$sub_time = date("D F d Y H:i:s.");
// mail form data to info@ginninderry.com.au
mail("info@ginninderry.com.au", "Online enquiry",
"Please contact the following potential client following an online enquiry\n
--------------------------------------------------------------\n
Name: $name\n
Phone: $phone\n
Fax: $fax\n
Email address: $email\n
Street address: $steet\n
Town/Suburb: $town\n
State: $state\n
Postcode: $postcode\n
Country: $country\n
Preferred reply method: $replymethod\n
---------------------------------------------------------------\n
User information\n
Client name and version: $HTTP_USER_AGENT\n
Clients IP address: $REMOTE_ADDR\n
Refering page: $HTTP_REFERER\n
---------------------------------------------------------------\n
Submission date and time: $sub_time\n
\n", "From: web@ginninderry.com.au\nReply-To: info@ginninderry.com.au\nX-Mailer: PHP/");
print "<h1>Thank you $name for your enquiry</h1>
<p>Ginninderry Homestead will respond by $replymethod to your enquiry shortly.</p>";
}
?>
so if i add the the extra text boxes at the top where the if (($name == "") or ($phone == "") or code is all should be right is that right?
hope you are still around would like some help as i'd like to help these people out i may just land them as clients.
they had issues with their designer and have made some chages themselves and things have not gone as they would of liked.