Page 1 of 1

html form

Posted: Sat Apr 03, 2004 6:04 pm
by kevinb
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">&nbsp;</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">&nbsp;</td>
</tr>
<tr>
<td width="167">No of Rooms:</td>
<td width="262">
<input type="text" name="street" size="20">
</td>
<td width="196">&nbsp;</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">&nbsp;</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">&nbsp;</td>
</tr>
<tr>
<td width="167">Arrival date:</td>
<td width="262">
<input type="text" name="postcode" size="20">
</td>
<td width="196">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp; </td>
</tr>
<tr>
<td width="167">&nbsp;</td>
<td width="262">&nbsp;</td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">&nbsp;</td>
<td width="262">&nbsp;</td>
<td width="196">&nbsp;</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\">&nbsp;</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\">&nbsp;</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\">&nbsp;</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\">&nbsp;</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\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">Postcode:</td>
<td width=\"217\"> <input type=\"text\" name=\"postcode\" value=\"$postcode\" size=\"6\"> </td>
<td width=\"116\">&nbsp;</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\">&nbsp;</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\">&nbsp;</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\">&nbsp; </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.

Posted: Sat Apr 03, 2004 9:07 pm
by Illusionist
wow, thats really sloopy...
Anyway, you probably don't have register_globals on. If this si the case then instead of just $name $address etc.... You need to use $_POST['name'], $_POST['address'] etc....

Hope that little information helped!

Posted: Sat Apr 03, 2004 9:54 pm
by kevinb
hi illusionist,
was just sent this stuff don't know php at all was looking for some information/help to reconstruct the from so it will work presenting the data as stated in the html form.
with the current variables as they are can i just add the variable at the beginning of the php form:
if (($name == "") or ($phone == "") or ($email == "") or ($town == "") or ($state == "") or ($country == ""))
{
where the if statement s are then again at the bottom of the form where it is asked to present information as an email
"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
just helping this person out if i can with some help from knowledgable others.
thanks again,
kevin

Posted: Sun Apr 04, 2004 7:21 pm
by kevinb
can anyone help with this.
just not confident to go it alone as i would be flying blind. i can't check it from my pc either so i'd have to send to owner to upload and check.
any help would be good.
thanks,
kevin

Posted: Sun Apr 04, 2004 9:13 pm
by Drayton
I've tried your code! it works just fine. What error message do you encounter running this application?

Posted: Mon Apr 05, 2004 12:09 am
by kevinb
HI drayton,
i am flying blind on this i was asked to look at this and know nothing about php :oops:
i have changed the variables as per instruction and made sure the text boxes were corresponding with variables.
then i added new variables to match new text boxes.
i am having trouble testing the form when i inputted my email address i got the page not found error and no mail.
i don't understand if i replaced old data with new why it won't work.
can't at the moment be more specific because i don't know what i'm talking about.
if you have the time and inclination could you run an eye over the new code and see if it works.

really appreciate some insight and help on this. they are nice people who like me need a break.
kevin
new form
<form name="contact" method="post" action="enquire2.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="mobile" size="20">
</td>
<td width="196">&nbsp;</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">&nbsp;</td>
</tr>
<tr>
<td width="167">No of Rooms:</td>
<td width="262">
<input type="text" name="NoRooms" size="20">
</td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">No of guests:</td>
<td width="262">
<input type="text" name="NoGuests" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">No of nights:</td>
<td width="262">
<input type="text" name="NoNights" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">Arrival date:</td>
<td width="262">
<input type="text" name="arrival" size="20">
</td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">Add'l requests:</td>
<td width="262">
<input type="text" name="requests" size="20">
<font size="-1"><font color="#FF0066"><b>*</b></font></font> </td>
<td width="196">&nbsp;</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">&nbsp;</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">&nbsp; </td>
</tr>
<tr>
<td width="167">&nbsp;</td>
<td width="262">&nbsp;</td>
<td width="196">&nbsp;</td>
</tr>
<tr>
<td width="167">&nbsp;</td>
<td width="262">&nbsp;</td>
<td width="196">&nbsp;</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
if (($name == "") or ($phone == "") or ($email == "") or ($mobile == "") or ($NoRooms == "") or ($NoGuests == "") or ($NoNights == "") or ($arrival == "") or ($requests == ""))
{
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\">Mobile:</td>
<td width=\"217\"> <input type=\"text\" name=\"mobile\" value=\"$mobile\" size=\"20\"> </td>
<td width=\"116\">&nbsp;</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\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">No of Rooms:</td>
<td width=\"217\"> <input type=\"text\" name=\"NoRooms\" value=\"$NoRooms\" size=\"20\"> </td>
<td width=\"116\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">No of guests:</td>
<td width=\"217\"> <input type=\"text\" name=\"NoGuests\" value=\"$NoGuests\" size=\"20\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">No of nights:</td>
<td width=\"217\"> <input type=\"text\" name=\"NoNights\" value=\"$NoNights\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">Arrival date:</td>
<td width=\"217\"> <input type=\"text\" name=\"arrival\" value=\"$arrival\" size=\"6\"> </td>
<td width=\"116\">&nbsp;</td>
</tr>
<tr>
<td width=\"157\">Add'l requests<font size=\"-1\"><font color=\"#FF0066\"></font></font>:</td>
<td width=\"217\"> <input type=\"text\" name=\"requests\" value=\"$requests\" size=\"10\"> <font size=\"-1\"><font color=\"#FF0066\"><b>*</b></font></font>
</td>
<td width=\"116\">&nbsp;</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\">&nbsp;</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\">&nbsp; </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
Mobile: $mobile\n
Email: $email\n
No of Rooms: $NoRooms\n
No of guests: $NoGuests\n
No of nights: $NoNights\n
Arrival date: $arrival\n
Add'l requests: $requests\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>";
}
?>

original reply message i did from the site. note that street address did not show.
Please contact the following potential client following an online enquiry
>
> --------------------------------------------------------------
>
> Name: kevin boyd
>
> Phone: 66552501
>
> Fax: 66552501
>
> Email address: kammboyd@bigpond.net.au
>
> Street address:
>
> Town/Suburb: bellingen
>
> State: nsw
>
> Postcode: 2454
>
> Country: australia
>
> Preferred reply method: email
>
> ---------------------------------------------------------------
>
> User information
>
> Client name and version: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.0; SIK30

Posted: Mon Apr 05, 2004 12:55 am
by Drayton
I've tried again your code and iot works just fine. check this part of your code on enquire.html:

<form name="contact" method="post" action="enquire2.php">

maybe you fogot to rename your enquire.php to enquire2.php...


i hopr this solves your problem!

Posted: Mon Apr 05, 2004 1:09 am
by Drayton
Please contact the following potential client following an online enquiry

--------------------------------------------------------------

Name: test

Phone: test

Mobile: test

Email: test

No of Rooms: test

No of guests: test

No of nights: test

Arrival date: test

Add'l requests: test

Preferred reply method: email

---------------------------------------------------------------

User information

Client name and version: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Clients IP address:

Refering page:

---------------------------------------------------------------

Submission date and time: Mon April 05 2004 13:53:10.

I tried to mail it to myself and i recieved this kind of message...

Posted: Mon Apr 05, 2004 2:41 am
by kevinb
hi drayton,
if you received the message you got then it must be working :)
i will send it to the the owners and see if it works when they up load it.
thanks for the feed back appreciate it. :)
just don't understand what i did you when trying to post to myself,
have to look at it again with fresher eyes tomorrow.
thanks again,
kevin

Posted: Mon Apr 05, 2004 5:08 am
by kevinb
hi drayton,
ftp'd the pages and all is well thanks again.
i will have to learn this php stuff.
if you know of any sites that have good intro level tuts please pass them on or any books would be great.
kevin

Posted: Mon Apr 05, 2004 7:47 pm
by Drayton
kevin,

Just check out this site http://WWW.PHP.NET all you need to know about php is here. I think so cause it helped me too a lot!