midlandcanary Posted February 11, 2010 Share Posted February 11, 2010 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 it is finding it hard to match the variant names up...This is my first piece of PHP coding so i need a bit of help? it would be much asppreciated! <!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: [email protected]</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>--> <?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 (!empty($_POST["insert_into"])) { $sql = "insert into emails (`Name`,`Address`,`Phone`) VALUES "; for($i = 0;$i < count($_POST["Name1"]) ; $i++) { if (!empty($_POST["Name1"][$i])) $sql .= sprintf("( '%s','%s','%s' )," , mres($_POST["Name1"][$i]), mres($_POST["Address1"][$i]), mres($_POST["Phone1"][$i])); } $sql = substr($sql, 0, -1); echo $sql; // test mysql_query($sql) or die(mysql_error() . " - " . $sql); } if(isset($_POST["SUBMIT"])) { $Name = $_POST['Name']; $Address = $_POST['Address']; $age = $_POST['Phone']; $email = $_POST['EMAIL']; $Height= $_POST['Height']; $Date = $_POST['Date']; $GMName = $_POST['GMName']; $Sex = $_POST['Sex']; $Age1 = $_POST['Age1']; $biketype = $_POST['biketype']; $Name = $_POST['Name1']; $Address = $_POST['Address1']; $age = $_POST['Phone1']; $message .= "Name: \n"; $message .= $Name; $message .= "\n"; $message .= "Address: \n"; $message .= $Address; $message .= "\n"; $message .= "Phone Number: \n"; $message .= $age; $message .= "\n"; $message .= "Height: \n"; $message .= $Height; $message .= "\n"; $message .= "Date: \n"; $message .= $Date; $message .= "\n"; $message .= "GMName: \n"; $message .= $GMName; $message .= "\n"; $message .= "Sex: \n"; $message .= $Sex; $message .= "\n"; $message .= "Age1: \n"; $message .= $Age1; $message .= "\n"; $message .= "biketype: \n"; $message .= $biketype; $message .= "Name1: \n"; $message .= $Name1; $message .= "\n"; $message .= "Address1: \n"; $message .= $Address1; $message .= "\n"; $message .= "Phone1: \n"; $message .= $Phone1; $message .= "\n"; mail("[email protected]", "Subject: subject", $message, "From: $email"); Header("Location: bookingform.php"); } ?> <div id="maincontentheader"><form method="POST"> <table border="0" width=100% > <tr><td width="7%" >Main Contact:</td> </tr> <tr> <td >Name: </td> <td width="18%" ><input name="Name"></td> </tr> <tr> <td align="top">Address: </td> <td ><textarea input name="Address" maxlength="1000" cols="25" rows="6"></textarea></td> </tr> <tr> <td >Phone Number: </td> <td ><input name="Phone" size="20" maxlength="15"></td> </tr> <tr> <td >E-Mail: </td> <td ><input name="EMAIL" size="20" maxlength="20"></td> </tr> <tr> <td >Date: </td> <td ><input name="Date"></td> </tr> <table id="dataTable"> <tr id="dataTable" > <tr><td>Group Members:</td></tr> <td >Name:</td> <td > <input name="GMName"> </td> <td >Sex:</td> <td width="10%"> <select size="1" input name="Sex"> <option >Male</option> <option >Female</option> </select> </td> <td width="5%" >Age:</td> <td width="16%" > <input name="Age1"> </td> <td width="7%" >Height:</td> <td width="12%"> <select size="1" input name="Height"> <option >None</option> <option >36"</option> <option >3'7"-4'10"</option> <option >4'-11"-5'5"</option> <option >5'-6"-5'10"</option> <option >Over 5'10"</option> </select> </font> </td> <td width="6%" >Bike Type:</td> <td width="15%" > <input name="biketype"> </td> </tr> <?php for($i = 0;$i < $_SESSION["rows"];$i++) { echo ($i + 1) . ".:<br />" ?> Name:<input type="text" name="Name[]" value="<?php echo (isset($_POST["Name1"][$i])? htmlspecialchars($_POST["Name1"][$i]):''); ?>"> Address:<input type="text" name="Address[]" value="<?php echo (isset($_POST["Address1"][$i])? htmlspecialchars($_POST["Address1"][$i]):''); ?>"> Phone:<input type="text" name="Phone[]" value="<?php echo (isset($_POST["Phone1"][$i])? htmlspecialchars($_POST["Phone1"][$i]):''); ?>"> <br /> <?php } ?> <input name="add" type="submit" value="add new row"> <?php if ($_SESSION["rows"] > 1) { ?> <input name="remove" type="submit" value="remove one row"> <?php } ?> <tr> <td colspan="2"> <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> Working Example: http://www.rutlandcycling.co.uk/testing1/bookingform.php (not a spam site just in its testing phase) Thanks guys :-) Link to comment https://forums.phpfreaks.com/topic/191758-php-form-adding-group-members/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.