Jump to content

[SOLVED] what to do after login in


ls354

Recommended Posts

Hello everybody I been learning some PHP from a book and after a while of using google and not finding an answer I dediced to come here. Here's the problem I am trying to create a basic login page in PHP whitout using a database to reduce complexity at the moment ,but after I get the login successful, I have no idea on how to redirect the page to lets say a folder or page.

 

This is my php

 

<?php

session_start() ;

 

$passwords = array ("test" => "test");

 

if (!$_POST["username"] or !$_POST["password"]) {

echo "You must enter your username and password";

exit;

}

 

if ($_POST["password"] == $passwords[$_POST["username"]]) {

echo "Login successful";

$_SESSION["auth_username"] = $_POST["username"];

}

else {

echo "Login incorrect";

}

?>

 

Thank you in advance.

Link to comment
Share on other sites

where you have

 

echo "Login succesful";

 

echo a link, or use a header to automatically redirect the user to another page...

 

such as 

 

header("Location :members.php");

 

or

 

echo "<a href='members.php'>Member's Page</a>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.