PDA

View Full Version : Form to mail, not recieving email


blanchard
11-22-2012, 02:51 PM
Hello all,

Once I have ticked the activty I want to do and ticked the disclaimer box I click submit and that takes me to my Thankyou page, but I don't get an email sent to me.

Here's the booking form code


<div id="bookingform">

<form id="form1" name="form1" method="post" action="http://www.adventurewithin.net/sendresults.php">

<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="21%"><div align="left">Name </div></td>
<td width="46%"><input name="name" type="text" id="name" size="50" /></td>
<td width="14%">&nbsp;</td>
<td width="19%">&nbsp;</td>
</tr>
<tr>
<td><div align="left">Email</div></td>
<td><input name="email" type="text" id="email" size="50" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="left">Telephone</div></td>
<td><input name="Telephone" type="text" id="Telephone" size="50" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Medical form</td>
<td><a href="images/Medical-Form.jpg" target="_blank">&raquo; Medical form</a></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td colspan="4"><em>Please print and fill out our medical form stating any injuries, ailments or disabilities which your instructor should be made aware of prior to booking any activities through adventurewithin.net.</em></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><em>Please tick the boxes that apply</em></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4" bgcolor="#000000"><input type="checkbox" name="ViaFerrata" id="ViaFerrata" />
<strong>Via Ferrata</strong></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize4" id="Groupsize4" />
Group size 4 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize5" id="Groupsize5" />
Group size 5 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize6" id="Groupsize6" />
Group size 6 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize7" id="Groupsize7" />
Group size 7 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize8" id="Groupsize8" />
Group size 8 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize9" id="Groupsize9" />
Group size 9 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize10" id="Groupsize10" />
Group size 10 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize11" id="Groupsize11" />
Group size 11 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Groupsize12" id="Groupsize12" />
Group size 12 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Classic" id="Classic" />
Classic - 35.00 per person</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Extreme" id="Extreme" />
Extreme - 39.50 per person</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><em>Please select preferred booking dates</em></td>
</tr>
<tr>
<td><div align="left">From</div></td>
<td><input type ="text" id="datepickerG" size="15"></td>
<td><div align="left">To</div></td>
<td><input type ="text" id="datepickerH" size="15"></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4" bgcolor="#000000"><div align="left">
<input type="checkbox" name="Half_Day" id="Half_Day" />
<strong>Half Day Activity</strong></div></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="1-6" id="1-6" />
Group size 1 - 6 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="7-12" id="7-12" />
Group size 7 - 12 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="am" id="am" />
09:30am - 12:30pm Morning</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="pm" id="pm" />
13:30pm - 16:30pm Afternoon</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><strong>Activity Choices</strong> <em>(please select one)</em></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Ghyll_Scramble" id="Ghyll_Scramble" />
Ghyll Scramble</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Mountain_Walk" id="Mountain_Walk" />
Mountain Walk</td>
</tr>

<tr>
<td colspan="4"><input type="checkbox" name="Climbing" id="Climbing" />
Climbing</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><em>Please select preferred booking dates</em></td>
</tr>
<tr>
<td><div align="left">From</div></td>
<td><input type ="text" id="datepickerA" size="15"></td>
<td><div align="left">To</div></td>
<td><input type ="text" id="datepickerB" size="15"></td>
</tr>

<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4" bgcolor="#000000"><strong>
<input type="checkbox" name="Full_Day" id="Full_Day" />
Full Day Activity</strong></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="1-" id="1-" />
Group size 1 - 6 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="7-" id="7-" />
Group size 7 - 12 people</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="All_Day" id="All_Day" />
09:30am - 16:30pm All Day</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><strong>Activity Choices</strong> <em>(please select two)</em></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Ghyll_Scramble2" id="Ghyll_Scramble2" />
Ghyll Scramble</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Via_Ferrata2" id="Via_Ferrata2" />
Via Ferrata</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Climbing2" id="Climbing2" />
Climbing</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="Mountain_Walk2" id="Mountain_Walk2" />
Mountain Walk</td>
</tr>

<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td colspan="4"><em>Please select preferred booking dates</em></td>
</tr>
<tr>
<td><div align="left">From</div></td>
<td><input type ="text" id="datepickerC" size="15"></td>
<td><div align="left">To</div></td>
<td><input type ="text" id="datepickerD" size="15"></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4" bgcolor="#000000"><strong>
<input type="checkbox" name="Expeditions" id="Expeditions" />
Lake District Expeditions</strong></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="3_day_Wild_Camp" id="3_day_Wild_Camp" />
3 day Wild Camp</td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="2_night_Wild_Camp" id="2_night_Wild_Camp" />
2 night Wild Camp</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><em>Please select preferred booking dates</em></td>
</tr>
<tr>
<td><div align="left">From</div></td>
<td><input type ="text" id="datepickerE" size="15"></td>
<td><div align="left">To</div></td>
<td><input type ="text" id="datepickerF" size="15"></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">Dislcaimer:<br />
<span class="style2">Disclaimer text<span id="sprycheckbox1">
<input type="checkbox" name="disclaimer" id="disclaimer" />
Please tick to verify that you have read our disclaimer.<span class="checkboxRequiredMsg">Please read our disclaimer and tick the check box.</span></span></span></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td height="38" colspan="4">&nbsp;</td>
</tr>
</table>


</form>

</div>




and here's the php script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>sendresults</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Booking Enquiries - Adventurewithin.net';

// Your email address. This is where the form information will be sent.
$emailadd = 'info@adventurewithin.net';

// Where to redirect after form is processed.
$url = 'http://www.adventurewithin.net/Thankyou.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
</body>
</html>


any help would be much appreciated.

Thanks

edbr
11-23-2012, 12:44 AM
I checked the server in your email address and it is apacjhe so im assuming php is configured
this section has raised probl;ems in the past


if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
in crease the character legnth to a more realistic number ie




if ($j >= 200)
{echo "Name of form element $key cannot be longer than 20o characters";die;}
or delete that section completly and test again

blanchard
11-25-2012, 09:41 AM
Hello edbr,

Thanks for your reply, since posting this I asked the hosting company to change the server to Windows from Linux which they now have done.

I still cannot get this to work correctly

I posted a technical question to the team at the hosting site and this is the answer I got:

To prevent spam being sent through our webservers, there are certain conditions
that must be met before our SMTP servers will send the email.

Email must be sent to, or from, an existing email address hosted by Streamline.
This must be a mailbox on the same domain name on which the form to mail script
is being hosted.

To stop misuse of your form by third parties the sendmail_from variable should
be set to your Streamline hosted email address. While access to the php.ini
file is restricted on our shared environment, you can send this variable using
the ini_set() command, shown below. A fifth parameter, -f, should be added to
the sendmail function. This will set the name of the from email address.


In its basic form, a simple sendmail script will look like this:
<?php
ini_set("sendmail_from", "user@yourdomain.com");
mail($email_to, $email_subject, $email_message, $headers, "-fuser@yourdomain.com");
?>

Provided that your form to mail script meets the requirements above, you should
have no problems. Third party scripts using sendmail will also work on
Streamline servers, although some will need slight changes made in order to
work correctly.

Where in the script do I put the two lines, do they go in place of other lines of script or add too?

Cheers

blanchard
11-25-2012, 02:11 PM
The host had to refresh there server settings.

Now it sends ok.

New problem, I don't see any preferred dates in the returned email.

blanchard
11-25-2012, 06:28 PM
Ok solved it wahooooo!

I pasted this code in place of the original script

<script>
$(function() {
$(".datepicker").datepicker();
});
</script>


and made the input names the same as the id names for the dates


<td><input name="Date1" type ="text" class="datepicker" size="15" id="Date1"></td>
<td><div align="left">To</div></td>
<td><input name="Date2" type ="text" class="datepicker" size="15" id="Date2"></td>

edbr
11-26-2012, 12:51 AM
well done , great feeling when it works isnt it? :)

blanchard
11-26-2012, 07:33 AM
Yes, this gave me a bit of brain ache, took a few breaks in between searching for a solution and reading over and over. But I knew I would find a solution just a matter of time.

haha

edbr
11-26-2012, 07:34 AM
light bulb moments