-2

This is my first webpage in php.I have created a log in page.I have successfully logged in.I need to redirect the webpage to the user's profile with a message of welcome user. how to do it? This is my code where should i add the redirect code? thank you in advance

<?php
$servername="localhost";
$username="root";
$password="";
$dbname="userdetails";
$conn=mysqli_connect($servername,$username,$password,$dbname);
if(!$conn){
die("connection failed".mysqli_connect_error());
}
?>
<?php
$username=$_POST['username'];
$password=$_POST['password'];

$qry = "select * from userdetails where username='$username' AND password='$password'";
$LoginName="";
$result=$conn->query($qry);
if($result->num_rows>0){
while($loginuser=$result->fetch_assoc())
{
    $LoginName=$loginuser['username'];
}

}


?>
vimal kumar
  • 75
  • 1
  • 8
  • Follow the link `This question already has an answer here:` and you will see e very good answer. In future start by searching for an answer to your question that already exists. – RiggsFolly Nov 07 '15 at 10:38

1 Answers1

0

You can use this, but you have to make sure this is the first code to output on the page.

header('Location: page.php');
Thaillie
  • 1,362
  • 3
  • 17
  • 31