registration.php
==============
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" name="f1">
<table width="200" border="1">
<tr>
<td colspan="2"><div align="center"><strong>Registration</strong></div></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="txtname" /></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="txtaddres"></textarea></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="r1" value="male"/>Male
<input type="radio" name="r1" value="female"/>female
</td>
</tr>
<tr>
<td>Email</td>
<td><input type="email" name="txtemail" /></td>
</tr>
<tr>
<td>Mobile</td>
<td><input type="text" name="txtmobile" /></td>
</tr>
<tr>
<td>Website</td>
<td><input type="text" name="txtwebsite" /> </td>
</tr>
<tr>
<td>Hobby</td>
<td><input type="checkbox" name="c1[]" value="cricket" />cricket
<input type="checkbox" name="c1[]" value="Read" />Read
<input type="checkbox" name="c1[]" value="sleep" />Sleep
</td>
</tr>
<tr>
<td>Qulification</td>
<td>
<select name="qul[]" multiple="multiple">
<option >Select</option>
<option value="12th">12th</option>
<option value="Bca">BCA</option>
<option value="Mca">MCA</option>
</select>
</td>
</tr>
<tr>
<td>Photo</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="txtuname" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="txtpass" /> </td>
</tr>
<tr>
<td>City</td>
<td><select name="city">
<option >Select</option>
<option value="kalol">Kalol</option>
<option value="amdavad">Amedabad</option>
<option value="Kadi">Kadi</option>
<option value="mahuva">Mahuva</option>
<option value="rajkot">Rajkot</option>
</select>
</td>
</tr>
<tr>
<td>State</td>
<td>
<select name="state">
<option >Select</option>
<option value="gujarat">Gujarat</option>
<option value="up">UP</option>
<option value="Rajasthan">Rajasthan</option>
<option value="mp">MP</option>
<option value="Bihar">Bihar</option>
</select>
</td>
</tr>
<tr>
<td>Country</td>
<td>
<select name="country">
<option value="india">India</option>
<option value="us">US</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btninsert" value="Registration" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db('work');
if(isset($_POST['btninsert']))
{
$txtname=$_POST['txtname'];
$txtaddres=$_POST['txtaddres'];
$r1=$_POST['r1'];
$txtemail=$_POST['txtemail'];
$txtmobile=$_POST['txtmobile'];
$txtwebsite=$_POST['txtwebsite'];
$h=implode(',',$_POST['c1']);
$qul=implode(',',$_POST['qul']);
//this is image uploade
$file=$_FILES['file']['name'];
$randno=rand(1,5000000);
$image=$randno.$file;
//$image=$file.$randno;
move_uploaded_file($_FILES['file']['tmp_name'],'img/'.$image);
//move_uploaded_file($_FILES['file'],'img/'.$image,['tmp_name']);
//this is end
$txtuname=$_POST['txtuname'];
$txtpass=$_POST['txtpass'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$qr=mysql_query("insert into registration values('','$txtname','$txtaddres','$r1','$txtemail',$txtmobile,'$txtwebsite','$h','$qul','$image','$txtuname','$txtpass','$city','$state','$country')");
if(!$qr)
{
echo mysql_error();
}
else
{
header('location:select.php');
}
}
?>
========
login.php
========
<?php
session_start()
?>
<form name="f1" method="post">
<label>User<input type="text" name="txtuser"></label>
<label>password<input type="password" name="txtpass"></label>
<input type="submit" name="btnlogin">
</form>
<?php
if(isset($_POST['btnlogin']))
{
if($_POST['txtuser']=="mitul" && $_POST['txtpass']=="mitul")
{
$_SESSION['hello']=$_POST['txtuser'];
header("location:select.php");
}
else{
echo "wong user name and password";
}
}
?>
========
logout.php
=========
<?php
session_start();
unset($_SESSION['hello']);
header("location:login.php");
?>
========
select.php
========
<?php
session_start();
?>
<a href="logout.php">Logout</a>
<?php
if(!isset($_SESSION['hello']))
{
header("location:login.php");
}
echo "<h2 style=color:red;>ADMIN ".$_SESSION['hello']."</h2>";
?>
<table border="1" style="width:1000px; height:150px;">
<tr>
<td>Name</td>
<td>Address</td>
<td>Gender</td>
<td>Email</td>
<td>Mobile</td>
<td>Website</td>
<td>Hobby</td>
<td>Qulification</td>
<td>Image</td>
<td>user name</td>
<td>Password</td>
<td>City</td>
<td>State</td>
<td>Country</td>
<td>Delete</td>
</tr>
<?php
mysql_connect("localhost","root","");
mysql_select_db('work');
$qr=mysql_query("select * from registration");
while($row=mysql_fetch_array($qr))
{
echo "<tr>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['gender']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['mobile']."</td>";
echo "<td>".$row['website']."</td>";
echo "<td>".$row['hobby']."</td>";
echo "<td>".$row['qulification']."</td>";
echo "<td><img src='img/".$row['images']."' height=100px; width=100px;></td>";
echo "<td>".$row['user_name']."</td>";
echo "<td>".$row['password']."</td>";
echo "<td>".$row['city']."</td>";
echo "<td>".$row['state']."</td>";
echo "<td>".$row['country']."</td>";
echo '<td><a href="delete.php?name='.$row['id'].'">Delete</a> <a href="update.php?name='.$row['id'].'">Update</a></td>';
echo "</tr>";
}
if(isset($_GET['msg']))
{
}
?>
======
delete.php
=======
<?php
session_start();
?>
<?php
mysql_connect("localhost","root","");
mysql_select_db('work');
$id=$_GET['name'];
$qr=mysql_query("delete from registration where id=$id");
if(!$qr)
{
echo mysql_error();
}
else
{
header("location:select.php?msg='Delete'");
}
?>
=========
update.php
=========
<?php
session_start()
?>
<?php
mysql_connect("localhost","root","");
mysql_select_db('work');
$id=$_GET['name'];
if(isset($id))
{
$qu=mysql_query("select * from registration where id=$id");
while($row=mysql_fetch_array($qu))
{
?>
<form method="post" enctype="multipart/form-data" name="f1">
<table width="200" border="1">
<tr>
<td colspan="2"><div align="center"><strong>Registration</strong></div></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="txtname" value="<?php echo $row[1]; ?>" /></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="txtaddres" ><?php echo $row[2] ?></textarea></td>
</tr>
<tr>
<td>Gender</td>
<td>
<?php if($row[3]=='male')
{
echo
"<input type='radio' name='r1' value='male' checked />Male
<input type='radio' name='r1' value='female'/>female"; }
if($row[3]=='female')
{
echo "<input type='radio' name='r1' value='male' />Male
<input type='radio' name='r1' value='female' checked/>female"; }
?>
</td>
</tr>
<tr>
<td>Email</td>
<td><input type="email" name="txtemail" value=<?php echo $row[4]; ?> /></td>
</tr>
<tr>
<td>Mobile</td>
<td><input type="text" name="txtmobile" value=<?php echo $row[5]; ?> /></td>
</tr>
<tr>
<td>Website</td>
<td><input type="text" name="txtwebsite" value=<?php echo $row[6]; ?> /> </td>
</tr>
<tr>
<td>Hobby</td>
<td>
<?php
$h=$row[7];
$hob=explode(',',$h);
?>
<input type="checkbox" name="c1[]" value='cricket'
<?php if(in_array('cricket',$hob)) { echo 'checked=checked'; } ?> />cricket
<input type="checkbox" name="c1[]" value="Read" <?php if(in_array('Read',$hob)){ echo 'checked=checked'; } ?> />Read
<input type="checkbox" name="c1[]" value="sleep" <?php if(in_array('sleep',$hob)) { echo 'checked=checked'; } ?> />Sleep
</td>
</tr>
<tr>
<td>Qulification</td>
<td>
<?php
$s=$row[8];
$se=explode(',',$s);
?>
<select name="qul[]" multiple="multiple">
<option >Select</option>
<option value="12th" <?php if(in_array('12th',$se)) { echo 'selected=selected'; } ?>>12th</option>
<option value="Bca" <?php if(in_array('Bca',$se)) { echo 'selected=selected';} ?>>BCA</option>
<option value="Mca" <?php if(in_array('Mca',$se)) {echo 'selected=selected'; } ?> >MCA</option>
</select>
</td>
</tr>
<tr>
<td>Photo</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="txtuname" value="<?php echo $row[11]; ?>"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="txtpass" value="<?php echo $row[12]; ?>" /> </td>
</tr>
<tr>
<td>City</td>
<td>
<select name="city">
<option >Select</option>
<option value="kalol"<?php if($row['city']=='kalol'){ echo 'selected=selected';} ?>>Kalol</option>
<option value="amdavad" <?php if($row['city']=='amdavad') { echo 'selected=selected';} ?>>Amedabad</option>
<option value="Kadi" <?php if($row['city']=='Kadi') { echo 'selected=selected'; } ?>>Kadi</option>
<option value="mahuva" <?php if($row['city']=='mahuva') { echo 'selected=selected'; } ?>>Mahuva</option>
<option value="rajkot" <?php if($row['city']=='rajkot') { echo 'selected=selected'; } ?>>Rajkot</option>
</select>
</td>
</tr>
<tr>
<td>State</td>
<td>
<select name="state">
<option >Select</option>
<option value="gujarat" <?php if($row['state']=='gujarat') { echo 'selected=selected'; } ?>>Gujarat</option>
<option value="up" <?php if($row['state']=='up') { echo 'selected=selected'; } ?>>UP</option>
<option value="Rajasthan" <?php if($row['state']=='Rajasthan') { echo 'selected=selected'; } ?>>Rajasthan</option>
<option value="mp" <?php if($row['state']=='mp') { echo 'selected=selected'; } ?>>MP</option>
<option value="Bihar" <?php if($row['state']=='Bihar') { echo 'selected=selected'; } ?>>Bihar</option>
</select>
</td>
</tr>
<tr>
<td>Country</td>
<td>
<select name="country">
<option value="india" <?php if($row['country']=='india') { echo 'selected=selected'; } ?>>India</option>
<option value="us" <?php if($row['country']=='us') { echo 'selected=selected'; } ?>>US</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="sbt" value="Update" /></td>
</tr>
</table>
</form>
<!--
$txtadd=$row['address'];
echo "<form name=f1 method=post>";
echo "<input type='text' name='txtname' value=".$row['name']."> ";
//echo "<textarea name='txtaddres'>$txtadd</textarea>";
//echo "<input type='text' name='txtaddress' value=$txtadd>";
echo "<input type='text' name='txtaddress' value=".$row['address'].">";
echo "<input type='text' name='txtgender' value=".$row['gender'].">";
echo "<input type='text' name='txtemail' value=".$row['email'].">";
echo "<input type='text' name='txtmo' value=".$row['mobile'].">";
echo "<input type='text' name='txtwebsite' value=".$row['website'].">";
echo "<input type='text' name='txthobby' value=".$row['hobby'].">";
echo "<input type='text' name='txtqul' value=".$row['qulification'].">";
echo "<input type='text' name='txtimg' value=".$row['images'].">";
echo "<input type='text' name='txtuname' value=".$row['user_name']." >";
echo "<input type='text' name='txtpass' value=".$row['password'].">";
echo "<input type='text' name='txtcity' value=".$row['city'].">";
echo "<input type='text' name='txtstate' value=".$row['state'].">";
echo "<input type='text' name='txtcountry' value=".$row['country'].">";
echo "<input type='submit' name='sbt'>";
echo '</form>';-->
<?php } }?>
<?php
if(isset($_POST['sbt']))
{
$id=$_GET['name'];
$name=$_POST['txtname'];
$address=$_POST['txtaddres'];
$gender=$_POST['r1'];
$email=$_POST['txtemail'];
$mobile=$_POST['txtmobile'];
$website=$_POST['txtwebsite'];
$hobby=implode(",",$_POST['c1']);
$qul=implode(",",$_POST['qul']);
$uname=$_POST['txtuname'];
$pass=$_POST['txtpass'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$file=$_FILES['file']['name'];
if($file)
{
$randno=rand(1,5000000);
$image=$randno.$file;
move_uploaded_file($_FILES['file']['tmp_name'],'img/'.$image);
$qu=mysql_query("update registration set name='$name',address='$address',gender='$gender',email='$email',mobile='$mobile',website='$website',hobby='$hobby',qulification='$qul',images='$image',user_name='$uname',password='$pass',city='$city',state='$state',country='$country' where id=$id");
if(!$qu)
{
echo mysql_error();
}
else
{
echo "IMAGES";
header("Location:select.php");
}
}
else
{
$qu=mysql_query("update registration set name='$name',address='$address',gender='$gender',email='$email',mobile='$mobile',website='$website',hobby='$hobby',qulification='$qul',user_name='$uname',password='$pass',city='$city',state='$state',country='$country' where id=$id");
if(!$qu)
{
echo mysql_error();
}
else
{
header("Location:select.php");
echo "WITHOUT IMAGE";
}
}
}
// $qu=mysql_query("update registration set name='Harish' where id=13");
?>