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";
}

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";
}

Perfect! You, sir, are a god amongst men.

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>";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.