Hey, i know that i ask it on wrong place, but still mabey some 1 can help me :)
I did start learn php few days ago.
I have problem whit my if else statement. So it shold redirect me on next page, but it wount and it redirect me back on login page.
I mean i get right value from login box and database, they match,but it still send me back index.php
There is prob some better solution to do login(eaven to do it only inside the login page). All help is welcome ^^
Here is login box in html.
I wount use atm CompanyName, but i prob to it later.
__________________________________________________ __________________________________________________ ________________
<div id="loginbox">
<form method="post" action="supplier_login.php">
<table id="table">
<tr>
<td>Company name</td><td><input type="text" name="CompanyName"></td>
</tr>
<tr>
<td>Username</td><td> <input type="text" name="username"></td>
</tr>
<tr>
<td>Password </td><td><input type="text" name="password"></td>
</tr>
<tr></tr>
<tr>
<td><a href="forgot">Forgot password?</a></td><td><a href="singup">Singup</a></td>
</tr>
<tr>
<td></td><td><input id="button" type="submit" value="Login"></td>
</tr>
</table>
</form>
</div>
__________________________________________________ __________________________________________________ _____________
Here is php code whis shold redirect Forward or backwards
<?php
$con=mysqli_connect("localhost ","abc","abc123 ","bd");
// Check connection
if (mysqli_connect_errno())
{
header("Location: index.php");
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT `Username`,`Password` FROM `supplier`");
while($row = mysqli_fetch_array($result)){
if($row['username'] === $_REQUEST["username"] && $row['password'] === $_REQUEST["password"]){
//if true redirect supplier.php
header('Location: supplier.php');
}else{
//else send back index.php
header("Location: index.php");
}
}
mysqli_close($con);
?>