please forgive naivety and innocence...I am not a programmer! I have spent the best part of 4 days on this and I am ready for a PHP lesson or intense therapy.
Scenario: DB built in mySQL. Table with all columns varchar(50) except ID and age - both INT. See below, I just need a 'Yes' value in the checkbox linked colums/fields.
I want to insert data with a form that has both textboxes and checkboxes. I thought best way to do this was php array...??
Form:
<form action="process.php" method="post" enctype="multipart/form-data">
<label>Childname
<input type="text" name="textfield[childname]" />
</label>
<p>
<label>Age
<input type="text" name="textfield[age]" />
</label>
</p>
<p>
<label>Parent Name
<input type="text" name="textfield[parent_name]" />
</label>
</p>
<p>
<label>Contact Number
<input type="text" name="textfield[contact_no]" />
</label>
</p>
<p>Subjects<br />
<label>
<input type="checkbox" name="checkbox[scratch]" value="checkbox" />
Scratch</label>
<label>
<input type="checkbox" name="checkbox[app_inventor]" value="checkbox" />
App Inventor</label>
<label>
<input type="checkbox" name="checkbox[html]" value="checkbox" />
HTML</label>
</p>
<p>Sessions Attended<br />
<label>
<input type="checkbox" name="checkbox[nov12]" value="checkbox" />
Nov 2012</label>
</p>
<p>
<label>
<input type="checkbox" name="checkbox[dec12]" value="checkbox" />
Dec 2012</label>
</p>
<p> </p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</form>
PHP script:
<?php
include("config.php");
$childrecord = array("childname","age","parent_name","contact_no","scratch","app_inventor","html");
if(isset($_POST['childrecord'])){
$childrecord = $_POST['childrecord'];
$i = 0;
foreach ($childrecord as $key => $value); {
$i++;
$sql="INSERT INTO tblchildren (childrecord) VALUES ($_POST['childrecord'])";
mysql_query($sql);
}
?>
Please help! Thanks in advance....