ImDifferent Posted June 23, 2016 Share Posted June 23, 2016 (edited) <?php session_start(); $username=$_POST['username']; $password=$_POST['password']; if($username&&$password) { $connect = mysqli_connect("localhost", "root", "", "login") or die("Couldnt connect to Database"); $query = mysqli_query($connect, "SELECT * FROM users WHERE username='$username'"); $numrows = mysqli_num_rows($query); if($numrows!==0) { while($row = mysqli_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if($username==$dbusername&&$password==$dbpassword) { echo "You are logged in!"; $_SESSION['username'] = $username; } else echo "Your password is incorrect!"; } else die("That user dosnt exist!"); } else die("Please enter a username and password"); ?> How DO i get this to redirect after checking the database ? Link to comment https://www.neowin.net/forum/topic/1301270-redirect-after-form/ Share on other sites More sharing options...
0 Steven P. Administrators Posted June 23, 2016 Administrators Share Posted June 23, 2016 Moved to correct forum, welcome to Neowin surabhishah143 1 Share Link to comment https://www.neowin.net/forum/topic/1301270-redirect-after-form/#findComment-597468906 Share on other sites More sharing options...
Question
ImDifferent
<?php
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
if($username&&$password)
{
$connect = mysqli_connect("localhost", "root", "", "login") or die("Couldnt connect to Database");
$query = mysqli_query($connect, "SELECT * FROM users WHERE username='$username'");
$numrows = mysqli_num_rows($query);
if($numrows!==0)
{
while($row = mysqli_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if($username==$dbusername&&$password==$dbpassword)
{
echo "You are logged in!";
$_SESSION['username'] = $username;
}
else
echo "Your password is incorrect!";
}
else
die("That user dosnt exist!");
}
else
die("Please enter a username and password");
?>
How DO i get this to redirect after checking the database ?
Link to comment
https://www.neowin.net/forum/topic/1301270-redirect-after-form/Share on other sites
1 answer to this question
Recommended Posts