So Friends In This Blog You Will Learn That, How You Can Create Signup Form For Your Website In Less Than Five Minute, So Read The Blog And Follow The Step.
I have also create a post, about Login Form , Visit The Link To Know, How You Can Create Login Form In Less Than 5 min.
So Create Signup.php File.
<?php
session_start();
if(isset($_SESSION['uname'])) // There is a condition, if user already have a session the it will redirect back to welcome page.
{
header("LOCATION:welcome.php");
exit();
}
else
{
?>
<br><br>
<h1 align="center"> Welcome To Signup Form </h1>
<form method="post" action="" align="center">
Name : <br><input type="text" name="name" placeholder="Enter Your Name"><br><br>
Email : <br><input type="text" name="email" placeholder="Enter Your Email"><br><br>
Password :<br> <input type="password" name="password" placeholder="Enter Your Password"><br><br>
<input type="submit" value="Signup" name="submit">
</form>
<?php
// so first we need to connect our form to the server... lets connect... :)
$con = mysqli_connect('localhost','root','','learn');
// This is the code to connect the form to the server, here we have to pass four parameter,
// The first parameter will be the Our Host Name,
// And the Second parameter will User Name of Database,
// And Third parameter will be the Password of The Database,
// And the fourth parameter will be the Name Of The Database.
// This is the code to connect the form to the server, here we have to pass four parameter,
// The first parameter will be the Our Host Name,
// And the Second parameter will User Name of Database,
// And Third parameter will be the Password of The Database,
// And the fourth parameter will be the Name Of The Database.
if(isset($_POST['submit'])) // Here Is The Condition That, If User Press On Submit Button The The Code Will Execute.
{
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
//Done..
//lets make the query ... ok
$query = "INSERT INTO `users` (`name`,`email`,`password`) VALUES ('$name','$email','$password')"; // This is the query to insert the value in Database.
$run = mysqli_query($con,$query); // here we need to pass two parameter first will, Database and second will our query.. ok
if ($run) // Checking The Code Is Successfully Run Or Not
{
echo "<script>alert('Signup Successfull')</script>";
}
else
{
echo "<script>alert('Failed To Signup')</script>";
}
}
?>
<br>
<div align="center">
<a href="login.php"> Alredy Registed, Login</a>
Great Information, Thakyou Sir
ReplyDelete