Я не знаю, как изменить вывод при входе в другой аккаунт. Вот мой код:
вывод.php
<?php
$con=mysqli_connect("localhost","root","","student");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$con->set_charset("utf8");
$result = mysqli_query($con,"SELECT * FROM data");
while($row = mysqli_fetch_array($result))
{
echo "<h3> Name: ". $row['last'] . " , " . $row['first']. " ".$row['middle']."</h3>"; //these are the fields that you have stored in your database table data
echo "<h3> StudentNo.: ". $row['studentno'] . ""."</h3>";
}
mysqli_close($con);
база данных для входа:
webdesign, php
<?php
include ("sq.php");session_start ();
if ($ _ SERVER ["REQUEST_METHOD"] == "POST") {// имя пользователя и пароль, отправленные с формы
$studentno = mysqli_real_escape_string($db,$_POST['studentno']);
$password = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT id FROM data WHERE studentno = '$studentno' and password = '$password'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = (isset($row['active']));
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
$_SESSION['studentno']= "studentno";
$_SESSION['login_user'] = $studentno;
$message = "Successfully LoggedIn!!";
echo "<script type='text/javascript'>alert('$message');</script>";
header("Refresh:0; url=output.html");
}else {
$message = "Invalid Student# or Password!!";
echo "<script type='text/javascript'>alert('$message');</script>";
header("Refresh:0; url=webdesign.html");
exit;
}
}