Jump to content

[SOLVED] Problems with outputs


plznty

Recommended Posts

if ( $_GET['view'] == 'process' )
{
    // Gathered Information
    $Zuser = $_POST['user'];
    $pass = $_POST['pass'];
    $cash = $_POST['cash'];
    $Zquestion = $_POST['question'];
    $Zanswer = $_POST['answer'];

    // Lowercase gathered information
    $user = strtolower($Zuser);
    $question = strtolower($Zquestion);
    $answer = strtolower($Zanswer);

    // Check whether $user exists or not
    $sql = "SELECT * FROM `users` WHERE `username` = '$user'";
    $rs = mysql_query($sql) or die(mysql_error());

    // If number of rows returned is more than 1, it means username is duplicated
    if ( mysql_num_rows($rs) > 1 ) {
        echo "Duplicate username!";
    }
    else {
        mysql_query("INSERT INTO users
   (username, password, money, current, rank, secretquestion, secretanswer) VALUES('$user', '$pass', '$cash', '0', 'noob', '$question','$answer' ) ")
        or die(mysql_error());

        echo "User Created!";
    }

}

It doesnt ever say "Duplicate username" when there is already a user in the sql table. It only works with user created. Otherwise if there is a duplicate it shows "Duplicate entry '' for key 2"

Link to comment
https://forums.phpfreaks.com/topic/163065-solved-problems-with-outputs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.