...

View Full Version : Form plus adding group members



Rutlandcycling
02-15-2010, 12:10 PM
Hi Guys,

Im currently building an activities site where people can book a bike trip in the uk. The trouble i am having is that there is often multiple people in a group with different statistics.

Ive managed to build a system where a group member can be added however the code will not send the information onto my e-mail I have asked around on a few other forums and they have no clue

Any Ideas?


<?php
session_start();

function mres($val)
{
return mysql_real_escape_string($val);
}

if (empty($_SESSION["rows"]))
$_SESSION["rows"] = 1;

if (!empty($_POST["add"])) {
$_SESSION["rows"]++;
}

if (!empty($_POST["remove"])) {
$_SESSION["rows"]--;
}

if (isset($_POST["SUBMIT"])) {
$message='';

$message.="Name:\n" . htmlspecialchars($_POST["Name"])."\n";
$message.="Address:\n" . htmlspecialchars($_POST["Address"])."\n";
$message.="Phone:\n" . htmlspecialchars($_POST["Phone"])."\n";
$message.="EMAIL:\n" . htmlspecialchars($_POST["EMAIL"])."\n";
$message.="Date:\n" . htmlspecialchars($_POST["Date"])."\n";


// collect group values!
for($i = 0;$i < $_SESSION["rows"];$i++) {

$message .= ($i + 1) . ". member:\n";
$message .= "Name :\n " . htmlspecialchars($_POST["GROUPMEMBER_Name"][$i]) . "\n";
$message .= "Sex :\n " . htmlspecialchars($_POST["GROUPMEMBER_Sex"][$i]). "\n";
$message .= "Age :\n " . htmlspecialchars($_POST["GROUPMEMBER_Age"][$i]) . "\n";
$message .= "Height :\n " . htmlspecialchars($_POST["GROUPMEMBER_Height"][$i]). "\n";
$message .= "biketype :\n " . htmlspecialchars($_POST["GROUPMEMBER_biketype"][$i]) . "\n";
$message .= "\n------------------------\n\n";

}

/*print"<pre>";
print_r($_POST);
print"</pre>";
print nl2br($message);
*/
$email="midlandcanary@gmail.com";

$headers = 'From: '.$email . "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set( 'sendmail_from', $email );
mail($email , "Subject: subject", $message, $headers );

unset($_SESSION["rows"]);
Header("Location: bookingform.php");
die();
}



if (isset($_POST))
$P = $_POST;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Rutland Activities | Cycle Hire | Climbing Wall | High Ropes</title>


<link href="/testing1/activitystyles.css" rel="stylesheet" type="text/css" />
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript">
</script>
</head>

<body>


<div id="container">
<div id="header">
<div id="logo">
<img src="/testing1/RutlandActivitiesImages/logo.png" alt="Rutland

Activities" width="400" height="90" /> </div>
<div id="headermid"><img

src="/testing1/RutlandActivitiesImages/icons.gif" alt="Rutland Activities" width="267"

height="80" /></div>
<div class="contactdetails">Call now! 01780 460 060<br /><br />
email: info@rutlandactivities.co.uk</div>
</div>
<div id="menubarpos">
<div id="menubar">
<script src="Scripts/ie6dropdownfix.js" type="text/javascript"></script>
<ul id="nav">
<li class="bookonlineicon"><a href="">Book Online</a> </li>
<li><a href="">Activities</a>
<ul>
<li><a href="">Cycle Hire</a></li>
<li><a href="">Climbing</a></li>
<li><a href="">Aerial Assault Course</a></li>
<li><a href="">Traverse Wall</a></li>
<li><a href="">Orienteering</a></li>
</ul>
</li>
<li><a href="">Group Visits</a>
<ul>
<li><a href="">Schools</a></li>
<li><a href="">Corporate/Teambuilding</a></li>
<li><a href="">Parties</a></li>
</ul>
</li>
<li><a href="">Events</a>
<ul>
<li><a href="">Events Calendar</a></li>
<li><a href="">Gallery</a></li>
</ul>
</li>
<li><a href="">Feedback</a> </li>
<li><a href="">Where To Find Us</a>
<ul>
<li><a href="">Whitwell</a></li>
<li><a href="">Normanton</a></li>
<li><a href="">Grafham</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="background">
<div id="mainimage">
<script type="text/javascript">
AC_FL_RunContent(

'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7

,0,19,0','width','999','height','319','title','Rutland

Activities','src','/testing1/RutlandActivitiesImages/mainmovie','quality','high','plugins

page','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','/testi

ng1/RutlandActivitiesImages/mainmovie' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0

,19,0" width="999" height="319" title="Rutland Activities">
<param name="movie" value="/testing1/RutlandActivitiesImages/mainmovie.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="/testing1/RutlandActivitiesImages/mainmovie.swf" width="999"

height="319" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"

type="application/x-shockwave-flash" wmode="transparent"></embed>
</object>
</noscript>
</div>
<!--<div id="maincontenttop"> </div>-->

<div id="maincontentheader"><form method="POST">

<table border="0" width=100% >
<tr><td width="7%" >Main Contact:</td>
</tr>
<tr>
<td >Name:&nbsp;</td>
<td width="18%" ><input name="Name" value="<?php echo isset($P["Name"])?strips($P["Name"]):'' ?>"></td>
</tr>
<tr>
<td align="top">Address:&nbsp;</td>
<td ><textarea input name="Address" maxlength="1000" cols="25"

rows="6"><?php echo isset($P["Address"])?strips($P["Address"]):'' ?></textarea></td>
</tr>
<tr>
<td >Phone Number:&nbsp;</td>
<td ><input name="Phone" size="20" maxlength="15" value="<?php echo isset($P["Phone"])?strips($P["Phone"]):'' ?>"></td>
</tr>
<tr>
<td >E-Mail:&nbsp;</td>
<td ><input name="EMAIL" size="20" maxlength="20" value="<?php echo isset($P["EMAIL"])?strips($P["EMAIL"]):'' ?>"></td>
</tr>
<tr>
<td >Date:&nbsp;</td>
<td ><input name="Date" value="<?php echo isset($P["Date"])?strips($P["Date"]):'' ?>"></td>
</tr>
<table id="dataTable">
<tr id="dataTable" ></tr>
<tr><td>Group Members:


<input name="add" type="submit" value="add new member">
<?php
if ($_SESSION["rows"] > 1) {

?>
<input name="remove" type="submit" value="remove one member">
<?php
}

?>

</td></tr>


<?php


function strips($val)
{
if (get_magic_quotes_gpc())
$val = stripslashes($val);
return htmlspecialchars($val);
}


for($i = 0;$i < $_SESSION["rows"];$i++) {

?>

<tr>
<td>Name:</td>
<td> <input name="GROUPMEMBER_Name[]" value="<?php echo isset($P["GROUPMEMBER_Name"][$i])?strips($P["GROUPMEMBER_Name"][$i]):'' ?>"> </td>

<td >Sex:</td> <td width="10%">

<select size="1" input name="GROUPMEMBER_Sex[]">
<option <?php echo (isset($P["GROUPMEMBER_Sex"][$i])AND $P["GROUPMEMBER_Sex"][$i] == "Male")?' selected':'' ?>>Male</option>
<option <?php echo (isset($P["GROUPMEMBER_Sex"][$i])AND $P["GROUPMEMBER_Sex"][$i] == "Female")?' selected':'' ?>>Female</option>
</select>
</td>
<td width="5%">Age:</td>
<td width="16%" > <input name="GROUPMEMBER_Age[]" value="<?php echo isset($P["GROUPMEMBER_Age"][$i])?strips($P["GROUPMEMBER_Age"][$i]):'' ?>"> </td>
<td width="7%" >Height:</td>

<td width="12%">

<select size="1" input name="GROUPMEMBER_Height[]" value="<?php echo isset($P["GROUPMEMBER_Height"][$i])?$P["GROUPMEMBER_Height"][$i]:'' ?>">
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == "None")?' selected':'' ?>>None</option>
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == '36"')?' selected':'' ?>>36"</option>
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == "3'7\"-4'10\"")?' selected':'' ?>>3'7"-4'10"</option>
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == "4'-11\"-5'5\"")?' selected':'' ?>>4'-11"-5'5"</option>
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == "5'-6\"-5'10\"")?' selected':'' ?>>5'-6"-5'10"</option>
<option <?php echo (isset($P["GROUPMEMBER_Height"][$i])AND $P["GROUPMEMBER_Height"][$i] == "Over 5'10\"")?' selected':'' ?>>Over 5'10"</option>
</select> </font> </td>
<td width="6%" >Bike Type:</td>
<td width="15%"> <input name="GROUPMEMBER_biketype[]" value="<?php echo isset($P["GROUPMEMBER_biketype"][$i])? strips($P["GROUPMEMBER_biketype"][$i]):'' ?>">

</td>
</tr>

<?php
}
?>
<tr>
<td colspan="2">&nbsp;
<input name="SUBMIT" type="submit" value="Book"></td>
<td width="4%"> </td>
</tr></table></table> </table>
</form></div>
<div id="maincontent">
<div id="uppermaincontent"></div>
<div id="lowermaincontent"></div>
</div>
<div id="footer">
<div id="sitemap">
<ul>
<li><span class="sitemapheader"><a href="">Activities</a>
</span>
<ul>
<li><span class="sitemapheader"><a href=""></a></span><a

href="">Cycle Hire</a></li>
<li><a href="">Climbing</a></li>
<li><a href="">Aerial Assault Course</a></li>
<li><a href="">Traverse Wall</a></li>
<li><a href="">Orienteering</a></li>
</ul>
</li>
<li><a href="" class="sitemapheader">Book Online</a> </li>
<li><a href="" class="sitemapheader">Group Visits</a>
<ul>
<li><a href="">Schools</a></li>
<li><a href="">Corporate/Teambuilding</a></li>
<li><a href="">Parties</a></li>
</ul>
</li>
<li><span class="sitemapheader"><a href="">Where To Find Us</a>
</span>
<ul>
<li><span class="sitemapheader"><a href=""></a></span><a

href="">Whitwell</a></li>
<li><a href="">Normanton</a></li>
<li><a href="">Grafham</a></li>
</ul>
</li>
<li><span class="sitemapheader"><a href="">Events</a>
</span>
<ul>
<li><span class="sitemapheader"><a href=""></a></span><a

href="">Events Calendar</a></li>
<li><a href="">Gallery</a></li>
</ul>
</li>
<li><a href="" class="sitemapheader">Feedback</a> </li>
</ul>
</div>
</div>
</div>
<div id="bottombar"></div>
</div>
</body>
</html>

mlseim
02-15-2010, 01:26 PM
Have you ever tested JUST the email part all by itself? Make sure it works?



<?php

$email="midlandcanary@gmail.com";
$message ="This is an email test.";

$headers = 'From: '.$email . "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set( 'sendmail_from', $email );
mail($email , "Subject: subject", $message, $headers );

?>

Rutlandcycling
02-15-2010, 01:40 PM
Have you ever tested JUST the email part all by itself? Make sure it works?



<?php

$email="midlandcanary@gmail.com";
$message ="This is an email test.";

$headers = 'From: '.$email . "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set( 'sendmail_from', $email );
mail($email , "Subject: subject", $message, $headers );

?>


Okay I'm a little bit naive when it comes to PHP (just learning) so what would be the best way to test it? Thanks

John

mlseim
02-15-2010, 01:52 PM
Save that script above as "test.php" and run it ... see if you get an email.
It should run all by itself.

If you don't see the email in your "inbox", make sure you check your "bulk, spam or filtered" email boxes.

Rutlandcycling
02-15-2010, 02:13 PM
Save that script above as "test.php" and run it ... see if you get an email.
It should run all by itself.

If you don't see the email in your "inbox", make sure you check your "bulk, spam or filtered" email boxes.

Tested that http://www.rutlandcycling.co.uk/testing1/MAILTEST.PHP

How would i link it to the script to test it? I'm confused :-(

mlseim
02-15-2010, 04:32 PM
Just going to the file should make it work:
http://www.rutlandcycling.co.uk/testing1/MAILTEST.PHP

But, I see that it fails, so there is some problem with it.

Who is your webhost?
Maybe they don't allow PHP mail() to be used?

I also notice there is a form ... so you are not using the test script from post #2 ???

Rutlandcycling
02-15-2010, 04:56 PM
Just going to the file should make it work:
http://www.rutlandcycling.co.uk/testing1/MAILTEST.PHP

But, I see that it fails, so there is some problem with it.

Who is your webhost?
Maybe they don't allow PHP mail() to be used?

I also notice there is a form ... so you are not using the test script from post #2 ???

I use Fasthosts....

Can you suggest somewhere else I can test it?

No Im not using the test script? Would you suggest swapping it with mine...:-)

mlseim
02-15-2010, 06:09 PM
Take the script in post #2 and save it as something, like "mytest.php" ... doesn't
matter what you call it. Then upload it to your webhost and go to the URL. It will run
the PHP script when you go to it's URL.

Go into Fasthost's documentation and see what they say about using PHP for emails.
Maybe they have some other method (like GoDaddy has)?

Rutlandcycling
02-16-2010, 08:44 AM
Take the script in post #2 and save it as something, like "mytest.php" ... doesn't
matter what you call it. Then upload it to your webhost and go to the URL. It will run
the PHP script when you go to it's URL.

Go into Fasthost's documentation and see what they say about using PHP for emails.
Maybe they have some other method (like GoDaddy has)?

Okay Ive tested that script you gave me? It worked and i received and E-mail?

What would you suggest is the problem?

Thanks for all your help :-)

mlseim
02-16-2010, 01:29 PM
OK ...

So now you know the actual email part works ... that's important.

Next, you'll have to figure out why the email section is not getting executed.
You know the email script works, so that means it must not be getting executed.

Start by inserting some test echoes to find out what values there are ...

Example, add the part in red and see what the value shows:

// collect group values!
echo "Number of rows: ".$_SESSION["rows"];
exit;
for($i = 0;$i < $_SESSION["rows"];$i++) {

That should show you how many rows there are and stop (halt program).

If that number is 0 (zero), or does not exist, that's why your email is not getting sent.

You'll use echo statements in various places to troubleshoot your problem.
Eventually, you'll see which statement is false, or which statement doesn't execute.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum