First Create 3 Things.
1. registration.html ( Create file)
2. registrationprocess.php ( Create file )
3. upload ( Create Directory )
1> Copy Following code in "registration.html" file.
<!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>Registration</title>
</head>
<body>
<form method="post" action="registrationprocess.php" enctype="multipart/form-data">
<table width="200" border="1">
<tr>
<td>Name:</td>
<td><input type="text" name="name" required="required" /></td>
</tr>
<tr>
<td>Gender:</td>
<td><input type="radio" name="gender" required="required" value="Male"/>Male
<input type="radio" name="gender" required="required" value="Female"/>Female</td>
</tr>
<tr>
<td>Photo:</td>
<td><input type="file" name="photo" required="required"/></td>
</tr>
<tr>
<td>discription</td>
<td><textarea name="discreption" required="required"></textarea></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pwd" minlength="6" required="required" /></td>
</tr>
<tr>
<td>Conform Password:</td>
<td><input type="password" name="repwd" minlength="6" required="required" /></td>
</tr>
</table>
<input type="submit" value="SUBMIT" />
</form>
</body>
</html>
Here, in <form> tag enctype="multipart/form-data" code is required for file upload.
2> Put following code in "registrationprocess.php" file.
<?php
$name=$_POST['name'];
$gender=$_POST['gender'];
//$photo=$_POST['photo'];
$discreption=$_POST['discreption'];
$pwd=$_POST['pwd'];
$repwd=$_POST['repwd'];
$dir="upload/";
$path=$dir.basename($_FILES['photo']['name']);
move_uploaded_file($_FILES['photo']['tmp_name'],$path);
if($pwd==$repwd)
{
$con=mysql_connect('localhost','root','');
if(!$con)
{
echo "Connection error".mysql_error();
}
$db=mysql_select_db('test1');
$query="insert into registration(name,gender,photo,discreption,password)values('$name','$gender','$path','$discreption','$pwd')";
echo $query;
$i=mysql_query($query,$con);
if($i>0)
{
echo "Successfull";
}
else
{
echo "Fail";
}
}
else
{
echo "Password not match";
}
?>
Here,
$dir="upload/";
$path=$dir.basename($_FILES['photo']['name']);
move_uploaded_file($_FILES['photo']['tmp_name'],$path);
code for file upload.
1. registration.html ( Create file)
2. registrationprocess.php ( Create file )
3. upload ( Create Directory )
1> Copy Following code in "registration.html" file.
<!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>Registration</title>
</head>
<body>
<form method="post" action="registrationprocess.php" enctype="multipart/form-data">
<table width="200" border="1">
<tr>
<td>Name:</td>
<td><input type="text" name="name" required="required" /></td>
</tr>
<tr>
<td>Gender:</td>
<td><input type="radio" name="gender" required="required" value="Male"/>Male
<input type="radio" name="gender" required="required" value="Female"/>Female</td>
</tr>
<tr>
<td>Photo:</td>
<td><input type="file" name="photo" required="required"/></td>
</tr>
<tr>
<td>discription</td>
<td><textarea name="discreption" required="required"></textarea></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pwd" minlength="6" required="required" /></td>
</tr>
<tr>
<td>Conform Password:</td>
<td><input type="password" name="repwd" minlength="6" required="required" /></td>
</tr>
</table>
<input type="submit" value="SUBMIT" />
</form>
</body>
</html>
Here, in <form> tag enctype="multipart/form-data" code is required for file upload.
2> Put following code in "registrationprocess.php" file.
<?php
$name=$_POST['name'];
$gender=$_POST['gender'];
//$photo=$_POST['photo'];
$discreption=$_POST['discreption'];
$pwd=$_POST['pwd'];
$repwd=$_POST['repwd'];
$dir="upload/";
$path=$dir.basename($_FILES['photo']['name']);
move_uploaded_file($_FILES['photo']['tmp_name'],$path);
if($pwd==$repwd)
{
$con=mysql_connect('localhost','root','');
if(!$con)
{
echo "Connection error".mysql_error();
}
$db=mysql_select_db('test1');
$query="insert into registration(name,gender,photo,discreption,password)values('$name','$gender','$path','$discreption','$pwd')";
echo $query;
$i=mysql_query($query,$con);
if($i>0)
{
echo "Successfull";
}
else
{
echo "Fail";
}
}
else
{
echo "Password not match";
}
?>
Here,
$dir="upload/";
$path=$dir.basename($_FILES['photo']['name']);
move_uploaded_file($_FILES['photo']['tmp_name'],$path);
code for file upload.
&
insert into registration(name,gender,photo,discreption,password)values('$name','$gender','$path','$discreption','$pwd')
code for insert in database.
3> Create Directory "upload"
0 comments:
Post a Comment