Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert into value of Radio button
    text
    copied!<p>I am trying to insert the value of a radio button when its checked into mysql db table. Below is the HTML and the PHP for doing so. Please let me know what is going wrong?</p> <blockquote> <p>Here is the HTML first:</p> </blockquote> <pre><code>&lt;div class='container'&gt; &lt;label for='username' &gt;Business*:&lt;/label&gt;&lt;br/&gt; &lt;input type="radio" name="bus" id="username" value="bus" maxlength="50" /&gt;&lt;br/&gt; &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class='container'&gt; &lt;label for='username' &gt;Personal*:&lt;/label&gt;&lt;br/&gt; &lt;input type="radio" name="pers" id="username" value="per" maxlength="50" /&gt;&lt;br/&gt; &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <blockquote> <p>Now the PHP:</p> </blockquote> <pre><code>function InsertIntoDB(&amp;$formvars) { $confirmcode = $this-&gt;MakeConfirmationMd5($formvars['email']); $formvars['confirmcode'] = $confirmcode; $insert_query = 'insert into '.$this-&gt;tablename.'( name, email, username, password, confirmcode, dob, business, personal ) values ( "' . $this-&gt;SanitizeForSQL($formvars['name']) . '", "' . $this-&gt;SanitizeForSQL($formvars['email']) . '", "' . $this-&gt;SanitizeForSQL($formvars['username']) . '", "' . md5($formvars['password']) . '", "' . $confirmcode . '", "' . $this-&gt;SanitizeForSQL($formvars['dob']) . '", "' . $this-&gt;SanitizeForSQL($formvars['bus']) . '", "' . $this-&gt;SanitizeForSQL($formvars['pers']) . '" )'; if(!mysql_query( $insert_query ,$this-&gt;connection)) { $this-&gt;HandleDBError("Error inserting data to the table\nquery:$insert_query"); return false; } return true; } </code></pre>
 

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