Gadgets

Friday, 19 December 2014

Insert Checkbox Values into MySQL Using PHP



Insert Checkbox Values into MySQL Using PHP

This article teaches you how to insert HTML form multiple checkbox values,dropdown select option values and radio button values into MySQL database using PHP. This article is easy to understand and I hope it will help you. 
<html>
<head>
<title>Student Registration</title>
</head>
<body>
<?php
include "database_connection.php";
if(isset($_POST["submit"])){
$sname  =   $_POST["sname"];
$fname  =   $_POST["fname"];
$gender =   $_POST["gender"];
$subjects    =   implode(",",$_POST["subjects"]);
$country    =   $_POST["country"];
$sql    =   "INSERT INTO  `studentinfo`(`studentname`,`fathername`,`gender`,`subjects`,`country`)
values("$sname","$fname","$gender","$subjects","$country")";
$query  =   mysql_query($sql) or die(mysql_error());
if
($query){
echo "<h1>Data inserted successful.....</h1>";
}else{
echo "<h1>Please Try again.....</h1>";
}
}
?>
<form name="registration" method="post" action="">
<table border="1" cellpadding="2" cellspacing="2" align="center">
<tr>
<td>Student Name :</td><td><input type="text" name="sname" required=""></td>
</tr>
<tr>
<td>Father Name:</td><td><input type="text" name="fname" required=""></td>
</tr>
<tr>
<td>Gender:</td><td><input type="radio" name="gender" value="male" required="">Male &nbsp;
<input type="radio" name="gender" value="female" >Female</td></tr>
<tr>
<td>Subjects:</td><td><input type="checkbox" name="subjects[]" value="maths">Maths &nbsp;<br>
<input type="checkbox" name="subjects[]" value="science">Science &nbsp; <br>
<input type="checkbox" name="subjects[]" value="computers">Computers &nbsp; <br>
<input type="checkbox" name="subjects[]" value="english">English &nbsp;</td></tr>
<tr><td>Country:</td>
<td><select name="country">
<option >----select----</option>
<option>India</option>
<option>Japan</option>
<option>USA</option>
</select></td></tr>
<tr><td></td>
<td><input type="submit" name="submit" value="Register"></td>
</tr>
</table>
</form>
</body>
</html>






Get the check box values from database in php

 



Friday, 28 November 2014

Create new database in mysql



Create new database in mysql:

After installed “phpmyadmin”
Open link  http://localhost/phpmyadmin  in any browser
In home page you will get an option i.e, “create new database”




In that text box type your database name and then click on “create”
Here I taken “university” is my database name





now your database created, add privileges to your database.
click on “privileges”


click on “add new user”


type your username and password as I showed in figure
click on “check all” and click on “go”



now you added privileges to your database
create a table in your database
you get option that “create new table on database”
type table name and number of fields
click on “go”


fill the field as I showed in figure and I taken that “student _id” is “primary key”
and click on “save”


now your table is created in your database
if you want add one more field to same table, you have a option that below table
I showed in figure
Click on “go” and add field to the same table


Now one more field added to your table







Thursday, 27 November 2014

Export database in mysql



 Export database in mysql :

Select database




Click on “Export”




Select SQL option 




click on  “Go”



    Tuesday, 14 October 2014

    Logout from gmail in HTC Desire 310 mobile

                                                             Sign into gmail account
                                                                  Check mails
                                                                Go to Settings
                                             Click on ACCOUNT >> Google


                                                    Click on your gmail account
                       Click on menu option and select Remove account
                                                            Click on Remove