Я пробовал разные коды, почти всегда одно и то же происходит, что может быть что-то с куки.
У меня есть этот код, который всегда показывает, не имеет значения, какой счет
echo "Hai " . $email . "
";
echo "Checking
";
echo "<a href='logout.php'>Logout</a>";
<form class="form-horizontal" action="" method="post" id="form1" style="width: 95%; margin: 0 2.5%" novalidate>
<div class="control-group">
<label class="control-label" for="ea">Email Address:</label>
<div class="controls">
<DIV align="left"><input type="text" name="email" id="email_addr_existing" class="input-large valid"></div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="pa">Password:</label>
<div class="controls">
<DIV align="left"><input type="password" name="password" id="login_password" class="input-large valid"></div>
</div>
</div>
<div class="control-group">
<div class="controls" id="exist_wait"></div>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> <DIV align="left"><input type="submit" name="Submit1" class="submit" value="Submit"></div></td>
</tr>
<?php
if (isset($_POST['Submit1'])){
$conn= mysqli_connect("localhost","root","");
if(mysqli_connect_error()) {
die('Could not connect: ' . mysqli_connect_error());
}
$conn->select_db('');
if (isset($_POST['email']) and isset($_POST['password'])){
//3.1.1 Assigning posted values to variables.
$email = $_POST['email'];
$password = $_POST['password'];
//3.1.2 Checking the values are existing in the database or not
$query = "SELECT email,password FROM `users1` COUNT WHERE email='$email' and password='$password'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
$count = mysqli_num_rows($result);
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
if ($count =0){
echo "Wrong email or password";
}
}elseif($count >0){
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
echo"Welcome.";
}
//3.1.4 if the user is logged in Greets the user with message
}else{
}
echo "Hai " . $email . "
";
echo "Checking
";
echo "<a href='logout.php'>Logout</a>";
?>
Структура таблицы:
CREATE TABLE `users1` (
`user_id` int(5) NOT NULL,
`username` varchar(25) NOT NULL,
`email` varchar(35) NOT NULL,
`password` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users1`
--
Я пробовал разные коды, почти всегда происходит одно и то же, что может быть что-то с куки.