<?php
session_start();
if(isset($_SESSION['uname'])) // ohh the error was here.. $_POST is wrong.. we need to user session
{
header("LOCATION:welcome.php");
exit();
}
else
{
}
// fixed ... :)
?>
<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');
if(isset($_POST['submit']))
{
$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')";
$run = mysqli_query($con,$query); // here we need to pass two parameter first will, Database and second will our query.. ok
if ($run)
{
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>
</div>
session_start();
if(isset($_SESSION['uname'])) // ohh the error was here.. $_POST is wrong.. we need to user session
{
header("LOCATION:welcome.php");
exit();
}
else
{
}
// fixed ... :)
?>
<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');
if(isset($_POST['submit']))
{
$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')";
$run = mysqli_query($con,$query); // here we need to pass two parameter first will, Database and second will our query.. ok
if ($run)
{
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>
</div>