<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Submit checkbox value to MySQL Archives -</title>
	<atom:link href="https://mitindia.in/tag/submit-checkbox-value-to-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/submit-checkbox-value-to-mysql/</link>
	<description></description>
	<lastBuildDate>Sat, 26 Nov 2016 06:59:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>Submit checkbox value to MySQL Archives -</title>
	<link>https://mitindia.in/tag/submit-checkbox-value-to-mysql/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Submit checkbox value to MySQL</title>
		<link>https://mitindia.in/submit-checkbox-value-to-mysql/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Tue, 21 Jun 2016 11:31:17 +0000</pubDate>
				<category><![CDATA[PHP-MySQL]]></category>
		<category><![CDATA[Submit checkbox value to MySQL]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=99</guid>

					<description><![CDATA[<p>Below example states that checkbox values can be stored into MySQL database using PHP program. Step 1: Create a table in MySQL with following screen shot. (Table name : Booked_Status) Step 2: Create connection string / configuration page as following example and name it &#8216;config2.php&#8217; &#60;?php $host="localhost"; $username="root"; $password=""; $dbname="demo"; $con=mysql_connect("$host","$username","$password"); mysql_select_db("$dbname",$con); ?&#62; Step 3: [&#8230;]</p>
<p>The post <a href="https://mitindia.in/submit-checkbox-value-to-mysql/">Submit checkbox value to MySQL</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Below example states that checkbox values can be stored into MySQL database using PHP program.</p>
<div>Step 1: Create a table in MySQL with following screen shot. (Table name : Booked_Status)</div>
<div class="separator"><img decoding="async" class="alignnone" src="https://1.bp.blogspot.com/-yhS3EK7MatY/VvDgAQWdmSI/AAAAAAAABOE/1K1cAfdwyokPrj6OtLIVCGGHuvs6Jpofg/s320/booking_status.JPG" width="320" height="154" border="0" /></div>
<div></div>
<div></div>
<div>Step 2: Create connection string / configuration page as following example and name it &#8216;config2.php&#8217;</div>
<div>
<pre>&lt;?php
      $host="localhost";
      $username="root";
      $password="";
      $dbname="demo";
      $con=mysql_connect("$host","$username","$password");
      mysql_select_db("$dbname",$con);
?&gt;</pre>
</div>
<div></div>
<div>Step 3: Now create a main page called &#8216;checkbox2mysql.php&#8217; with following code in it.</div>
<div>
<pre>&lt;html&gt;
&lt;head&gt; 
&lt;/head&gt; 
&lt;body&gt;
 &lt;h2&gt;Submit checkbox value to MySQL database in php&lt;/h2&gt;
 &lt;form method="post" action=""&gt;
Register No: &lt;input type=text name=t1&gt;
&lt;br&gt;
 &lt;input type="checkbox" name="chk[]" value="Booked"&gt;&lt;label&gt;Booked&lt;/label&gt;&lt;br/&gt;
 &lt;input type="checkbox" name="chk[]" value="Pending"&gt;&lt;label&gt;Pending&lt;/label&gt;&lt;br/&gt;
 &lt;input type="checkbox" name="chk[]" value="Rejected"&gt;&lt;label&gt;Rejected&lt;/label&gt;&lt;br/&gt;
 &lt;input type="submit" name="submit" Value="submit"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;?php error_reporting (E_ALL ^ E_NOTICE); ?&gt;
&lt;?php
include 'config2.php';
$t1=$_POST['t1'];

$query=mysql_query("select * from booked_status where regno='".$t1."' ") or die(mysql_error());
$duplicate=mysql_num_rows($query);

if (isset($_POST['submit']))
{
$chkbox = $_POST['chk'];
$i = 0;

if($duplicate==0)
    {

While($i&lt;sizeof($chkbox))
{
$query = "INSERT INTO booked_status (regno, status) VALUES ('$t1','".$chkbox[$i]."')";
mysql_query($query) or die(mysql_error());
$i++;
}
echo "&lt;center&gt;&lt;h2 style='background-color:green; color:white; display:inline'&gt;&lt;span&gt;Successfully updated.&lt;/span&gt;";
 }
 else
    {
      echo "&lt;center&gt;&lt;h2 style='background-color:red; color:white; display:inline'&gt;&lt;span&gt;The Register No. '$t1' is already present in the booking table";
    }
}
?&gt;</pre>
</div>
<div></div>
<div>Finally, run the above program and see the following output.</div>
<div class="separator"><img fetchpriority="high" decoding="async" class="alignnone" src="https://3.bp.blogspot.com/-VBewueHEXaE/VvDhIWvvaMI/AAAAAAAABOQ/_t0WnzML_ekS8nnMKkXWZgu4TaDYZyplA/s400/checkbox2mysql.JPG" width="400" height="175" border="0" /></div>
<div></div>
<div></div>
<div>If you run the above program with same Reg Number more than once, it will show following alert message.</div>
<div class="separator"><img decoding="async" class="alignnone" src="https://4.bp.blogspot.com/-ZINlYjaixGs/VvDhv8m_JfI/AAAAAAAABOY/IVNsBAh1BH4vKSayEaMpzbxrWGCqNBlQg/s400/checkbox2mysql2.JPG" width="400" height="156" border="0" /></div>
<div></div>
<div>That&#8217;s all for now! Thank you for referring our blog and don&#8217;t forget to share this with others!</div>
<div>Happy Coding!</div>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fsubmit-checkbox-value-to-mysql%2F&amp;linkname=Submit%20checkbox%20value%20to%20MySQL" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fsubmit-checkbox-value-to-mysql%2F&amp;linkname=Submit%20checkbox%20value%20to%20MySQL" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fsubmit-checkbox-value-to-mysql%2F&#038;title=Submit%20checkbox%20value%20to%20MySQL" data-a2a-url="https://mitindia.in/submit-checkbox-value-to-mysql/" data-a2a-title="Submit checkbox value to MySQL"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/submit-checkbox-value-to-mysql/">Submit checkbox value to MySQL</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
