I write 2 php files that show up user's info in the database when they type a correct user and display it again if they reopen browser. However when i reopen browser i receive this error msg :
Notice: Undefined index: full_name in C:\xampp\htdocs\test\session-database-2.php on line 3
wrong user please type again
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\test\session-database-1.php on line 1
1st is session-database-1.php
<?php session_start() ?>
<?php
echo "login Form";
echo "<form action='session-database-2.php' method='POST'>
name <input type='text' name='full_name' />
<input type='submit' value='submit'/>
</form>";
?>
2nd is
<?php session_start() ?>
<?php
$_SESSION['full_name']=$_POST['full_name'];
$host='localhost';
$username='root';
$password='root';
$dbname='pet';
$connect=mysqli_connect($host,$username,$password,$dbname) or die("can't connect to server");
$query="SELECT * FROM register WHERE full_name='{$_SESSION['full_name']}'";
$result=mysqli_query($connect,$query) or die("can't execute query");
if(mysqli_affected_rows($connect))
{
while($row=mysqli_fetch_assoc($result))
{
extract($row);
echo $full_name."<br/>";
echo $email."<br/>";
echo $phone."<br/>";
}
}
else
{
echo "wrong user please type again";
include "session-database-1.php";
exit();
}
?>