Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You want to store your form data in your code.</p> <p>For this you have to make following changes in your code and database.</p> <h1>In Form</h1> <pre><code>note: Input field value should be relevant. With your existing html code your process.php will get data in this structure Array ( [textfield] =&gt; Array ( [childname] =&gt; dang [age] =&gt; 18 [parent_name] =&gt; doctor [contact_no] =&gt; 100 ) [checkbox] =&gt; Array ( [scratch] =&gt; checkbox [app_inventor] =&gt; checkbox [html] =&gt; checkbox [nov12] =&gt; checkbox [dec12] =&gt; checkbox ) [Submit] =&gt; Submit ) </code></pre> <p>So you need to modify your process.php</p> <p>Before that you have to modify structure of your table, follow these steps</p> <pre><code>1. Delete your existing table 2. Create new table DROP TABLE tblchildren ; CREATE TABLE tblchildren ( id INT AUTO_INCREMENT PRIMARY KEY, childname VARCHAR(30), age TINYINT, parent_name VARCHAR(30), contact_no VARCHAR(20), scratch ENUM('yes','no'), app_inventor ENUM('yes','no'), html ENUM('yes','no'), sesNov12Attnd ENUM('yes','no'), sesDec12Attnd ENUM('yes','no') ); </code></pre> <p>Since you are new to php so i have used basic function, I will suggest you to use switch from <strong>mysql to mysqli</strong></p> <h1>process.php</h1> <pre><code> &lt;?php $con=mysql_connect("hostname","username","pass"); $db=mysql_select_db('dbname', $con); //check form is submitted if(isset($_POST)){ //mysql_real_escape_string() prevents from sql injection. $childname= mysql_real_escape_string($_POST['textfield']['childname']); $age=mysql_real_escape_string($_POST['textfield']['age']); $parentName=mysql_real_escape_string($_POST['textfield']['parent_name']); $contactNo=mysql_real_escape_string($_POST['textfield']['contact_no']); $scratch=isset($_POST['checkbox']['scratch'])?'yes':'no'; $appInventor=isset($_POST['checkbox']['app_inventor'])?'yes':'no'; $html=isset($_POST['checkbox']['html'])?'yes':'no'; $nov12=isset($_POST['checkbox']['nov12'])?'yes':'no'; $dec12=isset($_POST['checkbox']['dec12'])?'yes':'no'; $sql="INSERT INTO tblchildren(childname, age, parent_name, contact_no, scratch,app_inventor,html, sesNov12Attnd, sesDec12Attnd ) VALUES ('$childname',$age,'$parentName','$contactNo','$scratch','$appInventor','$html','$nov12','$dec12')"; mysql_query($sql); }else{ echo "Form Not SUbmitted"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload