Create a Sign Up Form and Insert Data Into Database Using PHP - CodeTextPro | Web Tutorial | Technology

CodeTextPro.com Provides - Web design, Technology gyan, Digital marketing, Online earnings, Seo, Adsense, Technology news, Motivation and inspiration, Latest Technology Affairs, Gadgets, Blogging

Friday, December 14, 2018

Create a Sign Up Form and Insert Data Into Database Using PHP



SignUp.html

<!doctype html>
<html>
<head>
<title>Register Form</title>
</head>
<table>
<form action="register.php" method="post">
<tr> <td> Name</td><td><input type="text" name="name">
 </td> </tr>
<tr> <td> Email</td><td><input type="text" name="Email">
  </td> </tr>
<tr> <td> Password</td><td><input type="password" name="pass">
 </td> </tr>
<tr> <td> Confirm Password</td><td><input type="password" name="c_pass">
</td> </tr>
<tr> <td> </td>
                <td><input type="reset" value="reset">
<input type="submit" value="Sign up">
                </td> </tr>
</form>
</table>
</html>





register.php

<?php
$server="localhost";
$user="root";
$pass="";
$db="hanif";

$name=$_POST['name'];
$email=$_POST['Email'];
$upass=md5($_POST['pass']);
$cpass=md5($_POST['c_pass']);
$con=mysqli_connect($server,$user,$pass,$db);
if(!$con){
echo "not connected";
}
else {
echo "Submitted";
$sql="insert into users(name,email,pass)values('$name','$email','$upass')";
if($upass==$cpass){
if(mysqli_query($con,$sql)){
echo " Successfully";
}
else
echo "not inserted";
}
else
echo "mismatch";
}


?>









No comments:

Post a Comment