SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow I need help! user reg, script I made, one annoying problem!

    Hello, I just made this user registration script but im a newb and I cant find where my error is. There error is:
    Parse error: parse error, unexpected $ in /home/******/public_html/scripts/board/signup.php on line 55

    Line 55 is the last line of the script the ?> line?

    Here is the whole script (please spot the error and let me know what it is, thank you!):

    PHP Code:

    <?php
    if ($_REQUEST['action'] == "register") {

    if ((!
    $_POST['username']) || (!$_POST['password']) || (!$_POST['vpassword']) || (!$_POST['email_adress'])) {
    echo 
    "<b>You did not submit the following information:</b><br />";

    if (!
    $_POST['username']) {
    echo 
    "You must enter a username!<br />";
    }
    if (!
    $_POST['password']) {
    echo 
    "You must enter a password!<br />";
    }
    if (!
    $_POST['vpassword']) {
    echo 
    "You must verify your password, it must be the same as your password!<br />";
    }
    if (!
    $_POST['email_adress']) {
    echo 
    "You must enter a email adress!<br />";
    }
    require(
    "joinform.html");
    exit();
    } elseif (!
    $_POST['password'] == $_POST['vpassword']) {
    echo 
    "Your password was not the same as the password verification!";
    exit();
    } else {

    include(
    "./include.coz.php");
    $username strip_tags(trim($_POST['username']));
    $password strip_tags(trim($_POST['password']));
    $password md5($password);
    $email strip_tags(trim($_POST['email_adress']));
    $query1 mysql_query("SELECT username from users WHERE username='$username'"$link);
    $numrows1 mysql_num_rows($query1);
    $query2 mysql_query("SELECT email from users WHERE email='$email'"$link);
    $numrows2 mysql_num_rows($query2);
    if (
    $numrows1 0) {
    echo 
    "Your desired username is already taken. Please try again. Thank you.";
    require(
    "joinform.html");
    exit();
    } elseif (
    $numrows2 0) {
    echo 
    "Your desired email adress is already in use by another user. Please try again. Thank you.";
    require(
    "joinform.html");
    exit();
    } else {
    $userquery mysql_query("INSERT INTO users ('username', 'password', 'email', 'signup_date') VALUES ('$username', '$password', '$email', now())");
    if (!
    $userquery) {
    echo 
    "Your account could not be created, please contact the webmaster! user_query problem.";
    } else {
    echo 
    "Congradulations! Your account has been created. Please login.";
    }

    }

    }
    require(
    "joinform.html");
    ?>
    AbcArcade.com - free internet games!

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php 
    if ($_REQUEST['action'] == "register" )

     
     if ((!
    $_POST['username']) || (!$_POST['password']) || (!$_POST['vpassword']) || (!$_POST['email_adress']))
     {
      echo 
    "<b>You did not submit the following information:</b><br />"
      if (!
    $_POST['username'])
      {
       echo 
    "You must enter a username!<br />"
      } 
      if (!
    $_POST['password'])
      {
       echo 
    "You must enter a password!<br />"
      } 
      if (!
    $_POST['vpassword'])
      { 
       echo 
    "You must verify your password, it must be the same as your password!<br />"
      } 
      if (!
    $_POST['email_adress'])
      {
       echo 
    "You must enter a email adress!<br />"
      } 
      require(
    "joinform.html" ); 
      exit(); 
     }
     elseif (!
    $_POST['password'] == $_POST['vpassword'])
     { 
      echo 
    "Your password was not the same as the password verification!"
      exit(); 
     }
     else
     { 
      include(
    "./include.coz.php" ); 
      
    $username strip_tags(trim($_POST['username'])); 
      
    $password strip_tags(trim($_POST['password'])); 
      
    $password md5($password); 
      
    $email strip_tags(trim($_POST['email_adress'])); 
      
    $query1 mysql_query("SELECT username from users WHERE username='$username'"$link); 
      
    $numrows1 mysql_num_rows($query1); 
      
    $query2 mysql_query("SELECT email from users WHERE email='$email'"$link); 
      
    $numrows2 mysql_num_rows($query2); 
      if (
    $numrows1 0)
      { 
       echo 
    "Your desired username is already taken. Please try again. Thank you."
       require(
    "joinform.html" ); 
       exit(); 
      }
      elseif (
    $numrows2 0)
      { 
       echo 
    "Your desired email adress is already in use by another user. Please try again. Thank you."
       require(
    "joinform.html" ); 
       exit(); 
      }
      else
      {
       
    $userquery mysql_query("INSERT INTO users ('username', 'password', 'email', 'signup_date') VALUES ('$username', '$password', '$email', now())" ); 
       if (!
    $userquery)
       { 
        echo 
    "Your account could not be created, please contact the webmaster! user_query problem."
       }
       else
       { 
        echo 
    "Congradulations! Your account has been created. Please login."
       } 
      } 
     } 
    }
    require(
    "joinform.html" ); 
    ?>
    you were missing a } at the end... precisely why I prefer this style of coding.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly. It's easier to match up braces the way Cyborg has formatted your code.
    John

  4. #4
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great, Thank you guys, I will use that way from now on.
    AbcArcade.com - free internet games!

  5. #5
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I am having a problem with the mysql_num_rows.
    Error = Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mosummer/public_html/scripts/board/signup.php on line 38

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mosummer/public_html/scripts/board/signup.php on line 40
    AbcArcade.com - free internet games!

  6. #6
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone offer any insight??
    AbcArcade.com - free internet games!

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Your queries aren't working.

    And why do you have the $link variable in your query? You only need to reference the connection when selecting a DB.
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well I know my querys arent working but. Ya I think its because stupidly I put the $link in them, Thank you naramation
    AbcArcade.com - free internet games!

  9. #9
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my revised code, but the mysql num rows still doesnt work, it gives the same error:

    PHP Code:

    <?php
    if ($_REQUEST['action'] == "register"
    {

    if ((!
    $_POST['username']) || (!$_POST['password']) || (!$_POST['vpassword']) || (!$_POST['email_adress'])) 
    {
    echo 
    "<b>You did not submit the following information:</b><br />";

    if (!
    $_POST['username']) {
    echo 
    "You must enter a username!<br />";
    }
    if (!
    $_POST['password']) 
    {
    echo 
    "You must enter a password!<br />";
    }
    if (!
    $_POST['vpassword']) 
    {
    echo 
    "You must verify your password, it must be the same as your password!<br />";
    }
    if (!
    $_POST['email_adress']) 
    {
    echo 
    "You must enter a email adress!<br />";
    }
    require(
    "joinform.html");
    exit();
    } elseif (!
    $_POST['password'] == $_POST['vpassword']) {
    echo 
    "Your password was not the same as the password verification!";
    require(
    "joinform.html");
    exit();
    } else 
    {

    include(
    "./include.coz.php");
    $username strip_tags(trim($_POST['username']));
    $password strip_tags(trim($_POST['password']));
    $password md5($password);
    $email strip_tags(trim($_POST['email_adress']));
    $query1 mysql_query("SELECT username FROM users WHERE username='$username'");
    $numrows1 mysql_num_rows($query1);
    $query2 mysql_query("SELECT email FROM users WHERE email='$email'");
    $numrows2 mysql_num_rows($query2);
    if (
    $numrows1 0
    {
    echo 
    "Your desired username is already taken. Please try again. Thank you.";
    require(
    "joinform.html");
    exit();
    } elseif (
    $numrows2 0
    {
    echo 
    "Your desired email adress is already in use by another user. Please try again. Thank you.";
    require(
    "joinform.html");
    exit();
    } else 
    {
    $userquery mysql_query("INSERT INTO users ('username', 'password', 'email', 'signup_date') VALUES ('$username', '$password', '$email', now())");
    if (!
    $userquery
    {
    echo 
    "Your account could not be created, please contact the webmaster! user query problem.";
    } else 
    {
    echo 
    "Congradulations! Your account has been created. Please login.";
    }

    }

    }
    }
    require(
    "joinform.html");
    ?>
    AbcArcade.com - free internet games!

  10. #10
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Verify your connection.
    Verify your table and fieldnames.
    Make the one change I have marked below (Probably won't change your error. )

    I really don't see anything wrong with your code. I'm sorry.

    PHP Code:
    <?php
    if ($_REQUEST['action'] == "register" )
    {
      if ((!
    $_POST['username']) || (!$_POST['password']) || (!$_POST['vpassword']) || (!$_POST['email_adress']))
      {
        echo 
    "<b>You did not submit the following information:</b><br />";
        if (!
    $_POST['username'])
        {
          echo 
    "You must enter a username!<br />";
        }
        if (!
    $_POST['password'])
        {
          echo 
    "You must enter a password!<br />";
        }
        if (!
    $_POST['vpassword'])
        {
          echo 
    "You must verify your password, it must be the same as your password!<br />";
        }
        if (!
    $_POST['email_adress'])
        {
          echo 
    "You must enter a email adress!<br />";
        }
        require(
    "joinform.html");
        exit();
      }
      elseif (!
    $_POST['password'] == $_POST['vpassword']) // <<<--- Change this to ($_POST['password'] != $_POST['vpassword'])
      
    {
        echo 
    "Your password was not the same as the password verification!";
        require(
    "joinform.html");
        exit();
      }
      else
      {
        include(
    "./include.coz.php");
        
    $username strip_tags(trim($_POST['username']));
        
    $password strip_tags(trim($_POST['password']));
        
    $password md5($password);
        
    $email strip_tags(trim($_POST['email_adress']));
        
    $query1 mysql_query("SELECT username FROM users WHERE username='$username'" );
        
    $numrows1 mysql_num_rows($query1);
        
    $query2 mysql_query("SELECT email FROM users WHERE email='$email'" );
        
    $numrows2 mysql_num_rows($query2);
        if (
    $numrows1 0)
        {
          echo 
    "Your desired username is already taken. Please try again. Thank you.";
          require(
    "joinform.html" );
          exit();
        }
        elseif (
    $numrows2 0)
        {
          echo 
    "Your desired email adress is already in use by another user. Please try again. Thank you.";
          require(
    "joinform.html" );
          exit();
        }
        else
        {
          
    $userquery mysql_query("INSERT INTO users ('username', 'password', 'email', 'signup_date') VALUES ('$username', '$password', '$email', now())" );
          if (!
    $userquery)
          {
            echo 
    "Your account could not be created, please contact the webmaster! user query problem.";
          }
          else
          {
            echo 
    "Congradulations! Your account has been created. Please login.";
          }
        }
      }
    }
    require(
    "joinform.html" );
    ?>
    John


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •