Question: PHP , HTML and MySQL I am creating a website for a class and am struggling with connecting to the database and getting the login

PHP, HTML and MySQL
I am creating a website for a class and am struggling with connecting to the database and getting the login page to redirect the user to a welcome page when the information is valid.
requirements for the site
1. a form that will allow users to enter their login information and when submitted it will connect to the database to check their information and allow them to connect
2. a button that allows the users to click it to log out. Once the button is clicked, it should redirect the user to the logout page. This page should tell them they logged out.
3. Write the session control script that welcomes your user to the site once they log in so that the user knows their log in worked. This can be as simple as displaying "Welcome, UserID".
4. Add the session control script to each page so that the user's information is passed from page to page as they go through your site. This can also be as simple as "UserID is logged in."
here is the php for each page that i have so far:
connection.php
login.php
prepare("SELECT * FROM userslogin WHERE Username = :username AND Password = :password");
$stmt->bindParam(":username", $username);
$stmt->bindParam(":password", $password);
$stmt->execute();
if ($stmt->rowCount()>0){
$_SESSION['username']= $username;
header('Location: welcome.php');
} else {
echo "Invalid username or password";
} $dbc->close();
}
?>
welcome.php
logout.php

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!