Question: I have a login and register php files that are connected to a mysql database my register.php logs everythings into the database and my logon

I have a login and register php files that are connected to a mysql database my register.php logs everythings into the database and my logon screen verifys wether or not that user is in the database. The problem I am having is when the login page redirects to an account.php I want the user to see their information. Here is the code for the login.php

Login

Log In

Not registered yet? Register Here

connect_errno) { echo "

MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}

"; exit(); } $user_id = $_POST['user_id']; $password = $_POST['password']; $sql = "SELECT * from customers WHERE user_id LIKE '{$user_id}' AND password LIKE '{$password}' LIMIT 1"; $result = $mysqli->query($sql); if (!$result->num_rows == 1) { header('Location:login.php?failed=1'); } else { echo $_SESSION["user_id"] = $user_id; header("location: account.php"); // do stuffs } } ?>

Now here is the code for the account.php

$sql = "SELECT * FROM customers WHERE user_id='$user_id'"; $result = $mysqli->query($sql);

if($row = mysqli_fetch_array($result)) { $user_id = $row["user_id"]; $password = $row["password"]; $email = $row["email"]; $first_name = $row["first_name"]; $last_name = $row["last_name"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $gender = $row["gender"]; $phone = $row["phone"];

echo "

User Name : $use_id
Password : $password
Email : $email
First Name : $first_name
Last Name : $last_name
Address : $address
City : $city
State : $state
Zip Code : $zip
Gender : $gender
Phone : $phone
"; } ?>

Any help to get the user to see just their information that they registered would be apprieciated

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 Databases Questions!