0

So im trying to make a password login and im getting errors.

i got past my Unable to jump to row 0 error with this:

mysql_num_rows($result) >= 1

but now it wont jump to the row when the password is correct ether :/

here is the code; whats wrong with it?

$result = mysql_query("SELECT * FROM users WHERE CallSign LIKE '".$_POST['signin']."'");

$result1 = mysql_query("SELECT * FROM users WHERE Password1 LIKE '".$_POST['password']."'");

if (mysql_num_rows($result) >= 1 || mysql_num_rows($result1) >= 1)
{
    die('Could not connect: ' . mysql_error());
}
else if (mysql_result($result, 0) == mysql_result($result1, 0))
{
echo "<br>CallSign matches password";
setcookie("user", $_POST['signin']);
}
else
{
echo "<br>Incorrect Password/Callsign";
}
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by da(code)da
1

Hi,

if I understand your question, I think that's more easy to do like this :

$result = mysql_query("SELECT * FROM users WHERE CallSign = '".$_POST['signin']."' and Password1 = '".$_POST['password']."'");
if(mysql_num_rows($result) > 0){
    echo "<br>CallSign matches password";
    setcookie("user", $_POST['signin']);
}else{
    echo "<br>Incorrect Password/Callsign";
}
0

new problem with that. i just updated to php 5.4.4 and im getting errors again

$result = mysql_query("SELECT * FROM users WHERE CallSign = '".$_POST['signin']."' and Password1 = '".$_POST['password']."'");

if(mysql_num_rows($result) > 0)
{
    echo "Login Successful<br>";

    $row = mysql_fetch_array($result);

    setcookie("ID", $row["CallSign"]);

    echo "Welcome " . $row["FirstName"] . "(" . $row["CallSign"] . ")!<br />";

    echo "<a href='panel.php'>Enter Your Panel</a>";
}
else
{
    echo "<br>Incorrect Password/Callsign";
    echo "<br><a href='index.php'>Click Here to Return</a>";
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.