Page 1 of 1

Form mail wont work.....Blank output :-(

Posted: Fri Oct 28, 2005 3:33 pm
by rohabrar
Hey members,

I am new to this community, I am stuck in this problem -- I cant understand where I am wrong-- I am attaching the code --

There are four pages:

1. contact-us.php
2. confirmation.php

3.online.booking.php
4.booking-confirmation.php

Code for 2 and 4 is same but interestingly 4 is not working at all. Problems I am having is there is no subject going with emails. and there is no display of the fields user filled in confirmation page.Also, I want the script to show empty required field on the next page and tell user to go back to fill them.

contact-us.php and confirmation are working fine - I dont know whats wrong with online-booking and booking confirmation.php

CODE online-booking.php

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

Code: Select all

<form  method="post"  action="booking-confirmation.php" name="Booking" enctype="text/plain">
              <table align="center" border="0" cellpadding="0" cellspacing="0" width="97%">
                <tbody>
                  <tr> 
                    <td width="121" height="19"> <p><strong>First Name</strong></p></td>
                    <td width="11"><strong>:</strong></td>
                    <td width="359"><input name="firstname" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="18"> <p><strong>Last Name</strong></p></td>
                    <td><strong>:</strong></td>
                    <td><input name="lastname" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="19"> <p><strong>Home Telephone</strong></p></td>
                    <td><strong>:</strong></td>
                    <td><input name="hometel" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="19"> <p><strong>Work Telephone</strong></p></td>
                    <td><strong>:</strong></td>
                    <td><input name="worktel" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="24"> <p><strong>Email Address</strong></p></td>
                    <td><strong>:</strong></td>
                    <td><input name="email" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td colspan="3" valign="top">&nbsp;</td>
                  </tr>
                  <tr> 
                    <td valign="top"><strong>Address Details</strong></td>
                    <td valign="top">&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td height="19" colspan="3" valign="top">------------------------------------------------------------------------------------------</td>
                  </tr>
                  <tr> 
                    <td height="19" valign="top"> <p><strong>Street Address</strong></p></td>
                    <td valign="top"><strong>:</strong></td>
                    <td><input name="street" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="20" valign="top"><strong>State/County</strong></td>
                    <td valign="top"><strong>:</strong></td>
                    <td><input name="county" type="text" class="FormField" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="23" valign="top"><strong>Country</strong></td>
                    <td valign="top"><strong>:</strong></td>
                    <td>
<select name="country" class="FormField">
                        <option value=" " selected>(please select a country)
<option value="--">none
<option value="AF">Afghanistan 
<option value="AL">Albania 
<option value="DZ">Algeria 
<option value="AS">American Samoa
<option value="AD">Andorra 
<option value="AO">Angola
<option value="AI">Anguilla
<option value="AQ">Antarctica
<option value="AG">Antigua and Barbuda 
<option value="AR">Argentina 
<option value="AM">Armenia 
<option value="AW">Aruba 
<option value="AU">Australia 
<option value="AT">Austria 
<option value="AZ">Azerbaijan
<option value="BS">Bahamas 
<option value="BH">Bahrain 
<option value="BD">Bangladesh
<option value="BB">Barbados
<option value="BY">Belarus 
<option value="BE">Belgium 
<option value="BZ">Belize
<option value="BJ">Benin 
<option value="BM">Bermuda 
<option value="BT">Bhutan
<option value="BO">Bolivia 
<option value="BA">Bosnia and Herzegowina
<option value="BW">Botswana
<option value="BV">Bouvet Island 
<option value="BR">Brazil
<option value="IO">British Indian Ocean Territory
<option value="BN">Brunei Darussalam 
<option value="BG">Bulgaria
<option value="BF">Burkina Faso
<option value="BI">Burundi 
<option value="KH">Cambodia
<option value="CM">Cameroon
<option value="CA">Canada
<option value="CV">Cape Verde
<option value="KY">Cayman Islands
<option value="CF">Central African Republic
<option value="TD">Chad
<option value="CL">Chile 
<option value="CN">China 
<option value="CX">Christmas Island
<option value="CC">Cocos (Keeling) Islands 
<option value="CO">Colombia
<option value="KM">Comoros 
<option value="CG">Congo 
<option value="CD">Congo, the Democratic Republic of the 
<option value="CK">Cook Islands
<option value="CR">Costa Rica
<option value="CI">Cote d'Ivoire 
<option value="HR">Croatia (Hrvatska)
<option value="CU">Cuba
<option value="CY">Cyprus
<option value="CZ">Czech Republic
<option value="DK">Denmark 
<option value="DJ">Djibouti
<option value="DM">Dominica
<option value="DO">Dominican Republic
<option value="TP">East Timor
<option value="EC">Ecuador 
<option value="EG">Egypt 
<option value="SV">El Salvador 
<option value="GQ">Equatorial Guinea 
<option value="ER">Eritrea 
<option value="EE">Estonia 
<option value="ET">Ethiopia
<option value="FK">Falkland Islands (Malvinas) 
<option value="FO">Faroe Islands 
<option value="FJ">Fiji
<option value="FI">Finland 
<option value="FR">France
<option value="FX">France, Metropolitan
<option value="GF">French Guiana 
<option value="PF">French Polynesia
<option value="TF">French Southern Territories 
<option value="GA">Gabon 
<option value="GM">Gambia
<option value="GE">Georgia 
<option value="DE">Germany 
<option value="GH">Ghana 
<option value="GI">Gibraltar 
<option value="GR">Greece
<option value="GL">Greenland 
<option value="GD">Grenada 
<option value="GP">Guadeloupe
<option value="GU">Guam
<option value="GT">Guatemala 
<option value="GN">Guinea
<option value="GW">Guinea-Bissau 
<option value="GY">Guyana
<option value="HT">Haiti 
<option value="HM">Heard and Mc Donald Islands 
<option value="VA">Holy See (Vatican City State) 
<option value="HN">Honduras
<option value="HK">Hong Kong 
<option value="HU">Hungary 
<option value="IS">Iceland 
<option value="IN">India 
<option value="ID">Indonesia 
<option value="IR">Iran (Islamic Republic of)
<option value="IQ">Iraq
<option value="IE">Ireland 
<option value="IL">Israel
<option value="IT">Italy 
<option value="JM">Jamaica 
<option value="JP">Japan 
<option value="JO">Jordan
<option value="KZ">Kazakhstan
<option value="KE">Kenya 
<option value="KI">Kiribati
<option value="KP">Korea, Democratic People's Republic of
<option value="KR">Korea, Republic of
<option value="KW">Kuwait
<option value="KG">Kyrgyzstan
<option value="LA">Lao People's Democratic Republic
<option value="LV">Latvia
<option value="LB">Lebanon 
<option value="LS">Lesotho 
<option value="LR">Liberia 
<option value="LY">Libyan Arab Jamahiriya
<option value="LI">Liechtenstein 
<option value="LT">Lithuania 
<option value="LU">Luxembourg
<option value="MO">Macau 
<option value="MK">Macedonia, The Former Yugoslav Republic of
<option value="MG">Madagascar
<option value="MW">Malawi
<option value="MY">Malaysia
<option value="MV">Maldives
<option value="ML">Mali
<option value="MT">Malta 
<option value="MH">Marshall Islands
<option value="MQ">Martinique
<option value="MR">Mauritania
<option value="MU">Mauritius 
<option value="YT">Mayotte 
<option value="MX">Mexico
<option value="FM">Micronesia, Federated States of 
<option value="MD">Moldova, Republic of
<option value="MC">Monaco
<option value="MN">Mongolia
<option value="MS">Montserrat
<option value="MA">Morocco 
<option value="MZ">Mozambique
<option value="MM">Myanmar 
<option value="NA">Namibia 
<option value="NR">Nauru 
<option value="NP">Nepal 
<option value="NL">Netherlands 
<option value="AN">Netherlands Antilles
<option value="NC">New Caledonia 
<option value="NZ">New Zealand 
<option value="NI">Nicaragua 
<option value="NE">Niger 
<option value="NG">Nigeria 
<option value="NU">Niue
<option value="NF">Norfolk Island
<option value="MP">Northern Mariana Islands
<option value="NO">Norway
<option value="OM">Oman
<option value="PK">Pakistan
<option value="PW">Palau 
<option value="PA">Panama
<option value="PG">Papua New Guinea
<option value="PY">Paraguay
<option value="PE">Peru
<option value="PH">Philippines 
<option value="PN">Pitcairn
<option value="PL">Poland
<option value="PT">Portugal
<option value="PR">Puerto Rico 
<option value="QA">Qatar 
<option value="RE">Reunion 
<option value="RO">Romania 
<option value="RU">Russian Federation
<option value="RW">Rwanda
<option value="KN">Saint Kitts and Nevis 
<option value="LC">Saint LUCIA 
<option value="VC">Saint Vincent and the Grenadines
<option value="WS">Samoa 
<option value="SM">San Marino
<option value="ST">Sao Tome and Principe 
<option value="SA">Saudi Arabia
<option value="SN">Senegal 
<option value="SC">Seychelles
<option value="SL">Sierra Leone
<option value="SG">Singapore 
<option value="SK">Slovakia (Slovak Republic)
<option value="SI">Slovenia
<option value="SB">Solomon Islands 
<option value="SO">Somalia 
<option value="ZA">South Africa
<option value="GS">South Georgia and the South Sandwich Islands
<option value="ES">Spain 
<option value="LK">Sri Lanka 
<option value="SH">St. Helena
<option value="PM">St. Pierre and Miquelon 
<option value="SD">Sudan 
<option value="SR">Suriname
<option value="SJ">Svalbard and Jan Mayen Islands
<option value="SZ">Swaziland 
<option value="SE">Sweden
<option value="CH">Switzerland 
<option value="SY">Syrian Arab Republic
<option value="TW">Taiwan, Province of China 
<option value="TJ">Tajikistan
<option value="TZ">Tanzania, United Republic of
<option value="TH">Thailand
<option value="TG">Togo
<option value="TK">Tokelau 
<option value="TO">Tonga 
<option value="TT">Trinidad and Tobago 
<option value="TN">Tunisia 
<option value="TR">Turkey
<option value="TM">Turkmenistan
<option value="TC">Turks and Caicos Islands
<option value="TV">Tuvalu
<option value="UG">Uganda
<option value="UA">Ukraine 
<option value="AE">United Arab Emirates
<option value="GB">United Kingdom
<option value="US">United States 
<option value="UM">United States Minor Outlying Islands
<option value="UY">Uruguay 
<option value="UZ">Uzbekistan
<option value="VU">Vanuatu 
<option value="VE">Venezuela 
<option value="VN">Viet Nam
<option value="VG">Virgin Islands (British)
<option value="VI">Virgin Islands (U.S.) 
<option value="WF">Wallis and Futuna Islands 
<option value="EH">Western Sahara
<option value="YE">Yemen 
<option value="YU">Yugoslavia
<option value="ZM">Zambia
<option value="ZW">Zimbabwe
</select>
</td>
                  </tr>
                  <tr> 
                    <td colspan="2">&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </tbody>
              </table>
       
              &nbsp; 
              <table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
                <tbody>
                  <tr> 
                    <td width="139"><p> 
                        <input name="dbroom" value="Yes" checked="checked" type="checkbox">
                        <strong>Double Room</strong></p></td>
                    <td width="370"><p> 
                        <input name="twroom" value="Yes" type="checkbox">
                        <strong>Twin Room</strong></p></td>
                  </tr>
                  <tr> 
                    <td><p> 
                        <input name="fmroom" value="Yes" type="checkbox">
                        <strong>Family Room</strong></p></td>
                    <td><p> 
                        <input name="sroom" value="Yes" type="checkbox">
                        <strong>Single Room</strong></p></td>
                  </tr>
                  <tr> 
                    <td>&nbsp;</td>
                    <td><p>&nbsp; </p></td>
                  </tr>
                  <tr> 
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td height="20"> <p><strong>Number of Adults</strong></p></td>
                    <td><select name="adult" class="FormField">
                        <option value="0" selected="selected">0</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                      </select></td>
                  </tr>
                  <tr> 
                    <td height="21"> <p><strong>Number of Children</strong></p></td>
                    <td><select name="children" class="FormField">
                        <option value="0" selected="selected">0</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                      </select></td>
                  </tr>
                  <tr> 
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td height="22"> <p><strong>Date of Arrival</strong></p></td>
                    <td><input name="arrival" type="text" class="FormField" value="dd/mm/yyyy" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td height="19"> <p><strong>Date of Departure</strong></p></td>
                    <td><input name="departure" type="text" class="FormField" value="dd/mm/yyyyy" size="25" maxlength="60"></td>
                  </tr>
                  <tr> 
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td><p><strong>Contact Me By</strong></p></td>
                    <td><select name="contactme" class="FormField">
                        <option value="Home Telephone" selected="selected">Home 
                        Telephone</option>
                        <option value="Work Telephone">Work Telephone</option>
                        <option value="E-mail">E-mail</option>
                      </select></td>
                  </tr>
                  <tr> 
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td valign="top"><p><strong>Comments</strong></p></td>
                    <td><textarea name="msg" cols="30" rows="6" class="textField"></textarea></td>
                  </tr>
                  <tr> 
                    <td valign="top">&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr align="center"> 
                    <td valign="top">&nbsp; </td>
                    <td valign="top"><div align="left">
                        <input name="submit" value="Send Completed Form" type="submit" class="formButtonCopy">
                        <input name="reset" type="reset" class="formButton"  value="Reset">
                      </div></td>
                  </tr>
                </tbody>
              </table>
              <p>
                <?php
if ($submit) { // if the submit button was pressed

	if($firstname && $email && $street && $subject && $msg ) { //  if all fields were completed

		// check if email syntax is valid
		if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
		{

		  echo "The e-mail was not valid";

		}

		else {

$send_message .= "\nMESSAGE:\n";
$send_message .= $message;
$send_message .= "\nADDRESS:\n";
$send_message .= $street;
$send_message .= "\nE-MAIL:\n";
$send_message .= $email;




mail("$youremailaddress","$subject","$send_message");

echo "Your mail has been sent. Thank you for visiting my website!!";   // if all went well, display message

 } // end of is email valid or not
 
 } // end of if all fields were completed

else {

echo "$error_message<BR>"; // if not all were filled in, display error message

}


} // end php if statement

?>
              </p>
            </form>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ONLINE BOOKING CONFIRMATION PAGE CODE

Code: Select all

<?php $error_message = "Sorry, your request can't be processed.Please complete the required fileds. Thank You.";

		$youremailaddress="info@countrywoodlodge.ie"; // the email address of where the message will be sent 
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		
if ($submit) { // if the submit button was pressed
	$subject = "Enquiry details - Online Booking";
	$today = date("F j, Y, g:i a");

	if($firstname && $lastname && $hometel && $worktel && $email && $msg ) { //  if all fields were completed
		// check if email syntax is valid
		if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
			{	
			echo "<br>";
			echo "<b>E-mail request failed!</b>";
			echo "<br>";
			echo "<font color=\"#FF0000\">Please Go Back and complete the form with correct email address in the format of xxxxx@xxxx.xxx</font>"; 		
			 }

				else {
			$send_message .= "<table width=\"60%\" border=0 cellpadding=\"4\">";
			$send_message .= "<tr><td><b>Person's Name</b>";		
			$send_message .= "</td><td>";
			$send_message .= $_POST["firstname"];
			$send_message .= "&nbsp;";
			$send_message .= $_POST["lastname"];
			$send_message .= "</td></tr>";

			$send_message .= "<tr><td><b>Address</b></td>";
			$send_message .= "<td>";
			$send_message .= $_POST["street"];
			$send_message .= "</td></tr>";
			
			$send_message .= "<tr><td><b>email Address</b></td>";
			$send_message .= "<td>";
			$send_message .= $_POST["email"];
			$send_message .= "</td></tr>";


			$send_message .= "<tr><td><b>Telephone number</b></td>";
			$send_message .= "<td>";
			$send_message .= $_POST["hometel"];
			$send_message .= "</td></tr>";

			$send_message .= "<tr><td><b>Message</b></td>";	
			$send_message .= "<td>";
			$send_message .= $_POST["msg"];
			$send_message .= "</td></tr>";


		  $send_message .= "<tr><td><font size=\"1\">Powered by ITExpertSolution.com. For support please email:support@itexpertsolution.com</font></td></tr>";

I knw there are less fields than the actual form -- trust me I tried with all the fields it still dont work. When I fill this form I neither get an email nor the confirmationpage shows me some echo messages.

Any help be reallyy appreciated.

Wanna see in action please go to http://www.countrywoodlodge.ie/online-booking.php

Regards,
Rohab S. Brar
http://www.itexpertsolution.com/index.php
webdesign :: computer repairs Ireland

Burrito: Please use

Code: Select all

tags when [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting PHP Code In The Forums[/url][/size]

Posted: Fri Oct 28, 2005 10:06 pm
by mickd
is register_globals on in your phpini file? if not change stuff like $submit, $firstname etc to $_POST['submit'] etc.

Posted: Fri Oct 28, 2005 10:12 pm
by rohabrar
hey mickd...

First I dont have any phpini file on my server. :?: Is that essential??

I am just trying to create a simple contact and order form that emails all the content to client via email. Interesting thing is one page works one dosent- both pages have same code in the file where its posted to.

I think the tag you mentioned is $send_message .= $_POST["firstname"];

and I have it in the script already!!

Go to http://www.countrywoodlodge.ie/contact-us.php
http://www.countrywoodlodge.ie/online-booking.php

Try the forms yourself you will know what I am talking about!

Posted: Fri Oct 28, 2005 10:22 pm
by mickd
if your with shared hosting register_globals might be off which is why it doesnt work.

try these:

change

Code: Select all

if ($submit) {
//to
if($_POST['submit']) {

Code: Select all

if($firstname && $lastname && $hometel && $worktel && $email && $msg ) {
//to
  if($_POST['firstname'] && $_POST['lastname'] && $_POST['hometel'] && $_POST['worktel'] && $_POST['email'] && $_POST['msg'] ) {
or at the very top of your page you could add (before output is sent)

Code: Select all

ini_set('REGISTER_GLOBALS','on');
but i recommend the first option as its more safe to have register_globals off.

Posted: Fri Oct 28, 2005 10:43 pm
by x_sky58
ok,i am also a newbie..but i think your cannot get your output because the "if($submit) there,i think you should change it to "if(isset($submit)".

i hope this maybe can help you.

Posted: Fri Oct 28, 2005 10:55 pm
by rohabrar
Interesting....

I will try these two solutions-

But I still cant understand that I have same script on other page on the same website -- that works with no problem at all - evern the validations work!!

How can two same codes - not act same??
I provided teh URLS in above posts

Thanx guys

Regards

Posted: Fri Oct 28, 2005 11:55 pm
by mickd
oops didnt even notice that :oops:

should be if(isset($_POST['submit'])) { and same for the others i mentioned above.

Posted: Thu Nov 03, 2005 4:17 am
by rohabrar
mickd wrote:oops didnt even notice that :oops:

should be if(isset($_POST['submit'])) { and same for the others i mentioned above.
Hmmm interestingly.... I didnt have to do anything suggested :)

When I compared the two scripts, I had some extra code in <form> tag. just removed that code and BANG!! working :lol:

Thanx for help guys :D

Posted: Thu Nov 03, 2005 4:35 am
by Jenk
or at the very top of your page you could add (before output is sent)

Code: Select all

ini_set('REGISTER_GLOBALS','on');
but i recommend the first option as its more safe to have register_globals off.
It's also a problem that you cannot affect the use of register_globals with ini_set() as it is used before any of the script it run, much like you cannot change the effect of magic_quotes_gpc :)

Posted: Thu Nov 03, 2005 5:35 am
by timvw
The form seems to ignore the fact eg: me@timvw.info could be valid e-mail address...
A little search on this forum will provide you with beter regular expressions ;) (eg: http://www.iamcal.com/publish/articles/ ... ing_email/)