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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.