trying to recall a variable in two different PHP files, The first is the username and the other password. Theses were saved as:
$username = $_POST[“user”];
$password = $
‘user’ and ‘pass’ was the input tag name for the user to enter username and password this works fine when searching the database for the user. the problem is were i am trying to recall these variables to select all the data in the database in my settings file. My Login form PHP is:
<?php
session_start();
$host=”localhost”;
$dbuser=”root”;
$dbpassword=””;
$db=”mydb”;
$conn = mysqli_connect($host, $dbuser,$dbpassword);
mysqli_select_db($conn, $db);
if(isset($_POST[“login”]))
$username = $
$password = $_POST[“pass”];
$sql = mysqli_query($conn, “SELECT username, password FROM users WHERE username =’$username’AND password=’$password’ limit 1”);
if(mysqli_num_rows($sql)==1){
header(“location: DailyPlanner.php”);
}
else{
echo ‘<script>alert(“Wrong Login Details. Try Again!”)</script>’;
}
}
?>
And my settings file is:
<?php
session_start();
$host=”localhost”;
$dbuser=”root”;
$dbpassword=””;
$db=”mydb”;
$conn = mysqli_connect($host,$dbuser,$dbpassword);
mysqli_select_db($conn, $db);
$_POST[‘user’] = $username;
$
?>
Just says the variable is undefined and have researched a tonne and cant find a solution any help is appreciated.