EXAMPLE OF INSERT INTO DATABASE
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$email=$_POST['email'];
$sql="insert
into project1 values('$name','$age','$gender','$email')”;
$count=mysql_query($sql)or
die(mysql_error());
if($count==1)
{
header("location:index.php");
}
else
{
echo "Not Registered";
}
ACCEPT ALL KEYBOARD VALUES IN DATABASE
$address=mysql_real_escape_string($address1);
DON’T INSERT DUPLICATE VALUES IN DATABASE
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$email=$_POST['email'];
mysql_connect("localhost","root","");
mysql_select_db("hussain");
$sql="select
* from project1 where name='$name'";
$result=mysql_query("$sql");
$data=mysql_fetch_row($result);
if(mysql_num_rows($result))
{
echo "This
name is already existes pls enter another name";
}
else
{
$sql="insert into project1
values('$name','$age','$gender','$email','$password','$hobbies','$address','$pincode','$country','$image','0')";
$count=mysql_query($sql)or
die(mysql_error());
if($count==1)
{
header("location:index.php");
}
else
{
echo "Not Registered";
}
UPLOADING IMAGE
AND SAVING IN SPECIFIC LOCATION
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$email=$_POST['email'];
$image=$_FILES['image']['name'];
mysql_connect("localhost","root","");
mysql_select_db("hussain");
$sql="select
* from project1 where name='$name'";
$result=mysql_query("$sql");
$data=mysql_fetch_row($result);
if(mysql_num_rows($result))
{
echo "This
name is already existes pls enter another name";
}
else
{
$sql="insert into project1
values('$name','$age','$gender','$email','$image')";
$count=mysql_query($sql)or
die(mysql_error());
if($count==1)
{
header("location:index.php");
}
else
{
echo "Not Registered";
}
move_uploaded_file($_FILES["image"]["tmp_name"],
"image/" .
$_FILES["image"]["name"]);
echo "Stored in: " .
"image/" . $_FILES["image"]["name"];
}
}
HOW TO MULTIPLE CHECK BOX VALUES STORED INTO SINGLE VARIABLES
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$email=$_POST['email'];
//inside
a connection
$hobbies = mysql_real_escape_string(implode(',',
$_POST['hobbies']));
$sql="insert
into project1 values('$name','$age','$gender','$email','$'hobbies')";
$count=mysql_query($sql)or
die(mysql_error());
if($count==1)
{
header("location:index.php");
}
else
{
echo "Not Registered";
}
}
<tr>
<td
valign="bottom">Hobbies</td>
<td valign="bottom">
<input type="checkbox"
name="hobbies[]" value="Cricket"
id="hobbies[]">Cricket
<input type="checkbox"
name="hobbies[]" value="Football" id="hobbies[]">Football
<input type="checkbox"
name="hobbies[]" value="Hockey"
id="hobbies[]">Hockey
<input type="checkbox"
name="hobbies[]" value="Tennis"
id="hobbies[]">Tennis
</td>
</tr>
LOGIN FROM
if(isset($_POST['submit']))
{
mysql_connect("localhost","root","");
mysql_select_db("hussain");
$name=$_POST['name'];
$password=$_POST['password'];
//$ustatus=$_POST['user_status'];
$sql="SELECT * FROM
project1 WHERE name='$name' and password='$password'";
$count=mysql_query($sql);
$row =
mysql_fetch_assoc($count);
if( $row['name'] == $name
&& $row['password'] == $password )
{
$_SESSION['name']=$name;
//$_SESSION['user_status']=$ustatus;
header("location:admin.php");
} else
{
echo "Worng User Name and
Password";
header('location:index.php');
}
}
LOGOUT FROM
session_start();
session_unset($_POST['name']);
session_destroy();
header("location:index.php");
FORGET PASSWORD
if(isset($_POST['submit']))
{
mysql_connect("localhost","root","");
mysql_select_db("hussain");
$name=$_POST['name'];
$email=$_POST['email'];
$sql="SELECT * FROM
project1 WHERE name='$name' and email='$email'";
$count=mysql_query($sql);
$row =
mysql_fetch_assoc($count);
if( $row['name'] == $name &&
$row['email'] == $email )
{
echo "Your
Password is</br>" .$row['password'];
}
else
{
echo " Pls Enter a Valid
User Name and Email ID";
//header('location:Loginproject.php');
}
}