php guys -- database query, help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nxventures
    Confirmed User
    • Mar 2003
    • 574

    #1

    php guys -- database query, help!

    On my "add user" page I need a query that will check if the login supplied already exists and if it does I need the user to be redirected to signup.php?name=1.

    I am going on 40 something hours of no sleep, and I need to get this done, help is very much appreciated. And needed. Thanks a ton to whoever can help!!
    SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.
  • vending_machine
    Confirmed User
    • Jun 2002
    • 1070

    #2
    Code:
    $DBH = mysql_connect( ... );
    mysql_select_db( 'database', $DBH );
    $sql = "SELECT username FROM table WHERE username = 'foo'";
    $query_result = mysql_query( $sql, $DBH );
    
    if ( mysql_num_rows( $query_result ) hahahaha 1 )
    {
          header( "Location: [url]http://[/url]" . $_SERVER[ 'HTTP_HOST' ] . "/signup.php?name=1" );
    }

    Comment

    • nxventures
      Confirmed User
      • Mar 2003
      • 574

      #3
      thats almost exactly what i have, but does the same thing. no go.
      SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

      Comment

      • nxventures
        Confirmed User
        • Mar 2003
        • 574

        #4
        it just goes through the rest of the actions as if the header redirect doesn't fucking exist.
        SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

        Comment

        • vending_machine
          Confirmed User
          • Jun 2002
          • 1070

          #5
          Originally posted by nxventures
          it just goes through the rest of the actions as if the header redirect doesn't fucking exist.
          You should exit your code as well (immediately after the header statement):

          Code:
          exit();
          Do you have that? In addition, the header function will not work if you have already sent text to stdout.
          Last edited by vending_machine; 06-22-2003, 01:20 PM.

          Comment

          • Hansm
            Confirmed User
            • Jun 2002
            • 871

            #6
            $DBH = mysql_connect( ... );
            mysql_select_db( 'database', $DBH );
            $sql = "SELECT username FROM table WHERE username = 'foo'";
            $query_result = mysql_query( $sql, $DBH );

            if ( mysql_num_rows( $query_result ) hahahaha 1 )
            {
            header( "Location: http://" . $_SERVER[ 'HTTP_HOST' ] . "/signup.php?name=1" );
            exit();
            }

            Comment

            • nxventures
              Confirmed User
              • Mar 2003
              • 574

              #7
              I have no idea why I didn't exit my code, I write beautiful code, must be time to catch up on that sleep. Thanks a ton guys, you're fucking great.
              SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

              Comment

              Working...