|
-
Feb 22nd, 2010, 01:03 AM
#1
[RESOLVED] ID is the only field sent
Hi,
I am working on a website for my church but I can't for the life of me find where I am going wrong with the code below. The only field that gets sent to the database is the "id" field and I can't figure out what maybe stopping the other information from getting through.
HTML Code:
<!-- TemplateBeginEditable name="main" --><div class="edit"><form name="registeration" class="regform" form action="<?php $_SERVER['PHP_SELF'];?>" method="post" enctype="application/x-www-form-urlencoded" target="_self">
<h2>Child's Name and Address</h2>
<input name="id" type="text" /><br />
<label for="nameochild">Name of child:</label><br />
<input name="nameochild" type="text" /><br />
<label for="address">Address:</label><br />
<input name="address" type="text" /><br />
<label for="postcode">Postcode:</label><br />
<input name="postcode" type="text" /><br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Your Contact Details</h2>
<label for="landline">Land line:</label><br />
<input name="landline" type="text" /><br />
<label for="mobile">Mobile:</label><br />
<input name="mobile" type="text" /><br />
<label for="email">E-mail:</label><br />
<input name="email" type="text" /><br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Child's Birthdate and Year level</h2>
<label for="dob">Date of Birth:</label><br />
<input name="dob" type="text" /><br />
<label for="year">School Year Level:</label><br />
<input name="year" type="text" /><br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Consent</h2>
<input name="genconsent" type="checkbox" value="I consent">I consent</input>
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Child's Medical Condition</h2>
<label for="medical">Please identify any medication conditions or special circumstances relating to your child that the leaders <br /> and coordinators of Kids Club should be aware of:</label><br />
<textarea name="medical" cols="60" rows="8"></textarea> <br />
<br />
<input name="photo" type="checkbox" value="">I consent to my child's photo and/or video be taken and/or used in any future advertising.</input><br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<br />
<label for="guardian">Name of Parent or Care Giver:</label><br />
<input name="guardian" type="text" /><br /><br />
<label for="date">Date:</label>
<br />
<input name="date" type="text" />
<br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Attendance</h2>
<input name="mon" type="checkbox" value="Monday" /> Monday - Volleyball $26
<br/ ><input name="moncare" type="checkbox" value="After Hours Care" />After Hours Care $15
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>Extras</h2>
<p>Any kids attending Kids Club for the first time need to pay an additional $10 for a special Kids Club T-Shirt.</p>
<input name="t-shirt" type="checkbox" value="t-shirt">
T-Shirt $10</input>
<br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
<br />
<h2>How did you hear about this program?</h2>
<input name="church" type="checkbox" value="church" />Church
<input name="mailout" type="checkbox" value="Mailout" />Mail Out
<input name="wom" type="checkbox" value="WoM" />Word of Mouth<br />
<input name="letterbox" type="checkbox" value="letterbox" />Letterbox Drop
<input name="newspaper" type="checkbox" value="Newspaper" />Newspaper
<input name="internet" type="checkbox" value="internet" />Internet<br />
<input name="school" type="checkbox" value="school" />School (please specify) <input name="school" type="text" value="school" /><br />
<input name="other" type="checkbox" value="other" />Other (please specify) <input name="other" type="text" value="other" />
<br />
<br />
<input name="submit" type="submit" value="Submit Form" />
<input name="reset" type="reset" value="Reset Form" />
<br />
<br />
<a href="#top" tabindex="0" title="Back to top of page" target="_top">Back to top of page</a>
</form>
<br /> </div><!-- TemplateEndEditable name="main" -->
</div>
<div class="bottomnav">
<a href="home.php" title="Home">Home</a> | <a href="privacy.php" title="Privacy">Privacy</a> | <a href="mailto:[email protected]?subject=Malvern Uniting Church Kids Club Website Query" target="_blank" title="Contact Web Administrator">Web Administrator</a>
</div>
<div class="lastmod"><p>Last modified: <?php include ("time.php")?></p>
</div>
</div>
PHP Code:
<?php $id=""; $child=""; $address=""; $postcode=""; $landline=""; $mobile=""; $email=""; $dob=""; $grade =""; $phone=""; $genconsent=""; $medical =""; $photo=""; $guardian=""; $date="";
//connect to server or exit require_once("conroot.php");
//create database $query = "CREATE DATABASE IF NOT EXISTS $dbDatabase"; if (mysql_query($query, $conn)) { echo ("Database create query successful"); } //select database if (mysql_select_db($dbDatabase, $conn)) { echo ("Database selection successful"); }else { die ("Could not locate $dbDatabase database" .mysql_error()); } //create table $query = "CREATE TABLE IF NOT EXISTS $table ( ID int(2) NOT NULL auto_increment unique, Child varchar(30) default NULL, Address varchar(30) default NULL, Email varchar(50) default NULL, Mobile varchar(20) default NULL, Postcode varchar(6) default NULL, DOB varchar(20) default NULL, Grade varchar(2) default NULL, Phone varchar(10) default NULL, Consent varchar(20) default NULL, Medical varchar(100) default NULL, Photo varchar(1) default NULL, Guardian varchar(20) default NULL, Date varchar(8) default NULL, PRIMARY KEY (ID) ) TYPE=MyISAM";
if (mysql_query($query, $conn)) { //echo ("table query successful"); }else { //connect to database or exit if (!(mysql_select_db($dbDatabase, $conn))){ //echo '&message=db+selection+failed&'; exit; } }
//validate or send data. if($_SERVER['REQUEST_METHOD'] == "POST"){ // Make sure the data has been sent to the script from html //convert the POST variables from the html to local variables if(isset($_POST['id'], $_POST['child'], $_POST['address'], $_POST['postcode'], $_POST['landline'], $_POST['mobile'], $_POST['email'], $_POST['dob'], $_POST['year'], $_POST['genconsent'], $_POST['medical'],$_POST['photo'],$_POST['guardian'], $_POST['date'])){ $id = mysql_real_escape_string($_POST['id']); $child = mysql_real_escape_string($_POST['nameochild']); $address = mysql_real_escape_string($_POST['address']); $postcode = mysql_real_escape_string($_POST['postcode']); $landline = mysql_real_escape_string($_POST['landline']); $mobile = mysql_real_escape_string($_POST['mobile']); $email = mysql_real_escape_string($_POST['email']); $dob = mysql_real_escape_string($_POST['dob']); $grade = mysql_real_escape_string($_POST['year']); //$genconsent = mysql_real_escape_string($_POST['genconsent']); $medical = mysql_real_escape_string($_POST['medical']); //$photo = mysql_real_escape_string($_POST['photo']); $guardian = mysql_real_escape_string($_POST['guardian']); $date = mysql_real_escape_string($_POST['date']); } //send mysql a query to select records from the products table where the id's match. If the query fails exit if (!($result = mysql_query("SELECT * FROM $table where ID= '$id'"))){ echo '&message=query+failed&'; exit; } //Retrieve the number of rows (records)that have been returned from above query $num_results = mysql_num_rows($result); if($num_results <= 0) {//record does not exist so insert $query = "INSERT INTO kids (ID, Child, Address, Postcode, Landline, Mobile, Email, DOB, Grade, Medical, Guardian, Date) VALUES ('$id','$child', '$address', '$postcode', '$landline','$mobile','$email','$dob', '$grade','$medical ','$guardian','$date')"; if (mysql_query($query , $conn)){ $update = "UPDATE kids SET Child = '$child', WHERE ID = '$id'"; }else{ exit; } if(!mysql_query($update, $conn)){ echo "&message=the+details+have+been+updated&"; }else{ echo "&message=update+not+successful&"; } } } ?>
So far I have only coded the php up until the date field so I could make sure the php was working before continuing on with the rest of the code. I have compared this code with working code Id done before (look on my website) and as far as I can tell they are the same.
Edit:
The code for conroot.php can be found here.
Thanks,
Aaron
Last edited by Nightwalker83; Feb 22nd, 2010 at 01:22 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|