Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password Help

    I used the tutorial frm phpfreks to do the login system....however I wanted to modify it. I tryed to change teh code so that the user code input their password on the beginning form and here is what I got.

    PHP Code:
    <?

    include 'db.php'

    // Define post fields into simple variables
    $first_name $_POST['first_name'];
    $last_name $_POST['last_name'];
    $email_address $_POST['email_address'];
    $username $_POST['username'];
    $PASSWORD $_POST['PASSWORD'];
    $password_re $_POST['password_re'];

    /* Let's strip some slashes in case the user entered
    any escaped characters. */

    $first_name stripslashes($first_name);
    $last_name stripslashes($last_name);
    $email_address stripslashes($email_address);
    $username stripslashes($username);
    $PASSWORD stripslashes($PASSWORD);
    $password_re stripslashes($password_re);

    /* Do some error checking on the form posted fields */

    if((!$first_name) || (!$last_name) || (!$email_address) || (!$username) || (!$PASSWORD) || (!password_re)){
        echo 
    'You did not submit the following required information! <br />';
        if(!
    $first_name){
            echo 
    "First Name is a required field. Please enter it below.<br />";
        }
        if(!
    $last_name){
            echo 
    "Last Name is a required field. Please enter it below.<br />";
        }
        if(!
    $email_address){
            echo 
    "Email Address is a required field. Please enter it below.<br />";
        }
        if(!
    $username){
            echo 
    "Desired Username is a required field. Please enter it below.<br />";
        }
    if(!
    $PASSWORD){
            echo 
    "Desired password is a required field. Please enter it below.<br />";
    if(!
    $password_re){
            echo 
    "Retyping the password is a required field. Please enter it below.<br />";
        }
        }
        include 
    'join_form.html'// Show the form again!
        /* End the error checking and if everything is ok, we'll move on to
         creating the user account */
        
    exit(); // if the error checking has failed, we'll exit the script!
    }
        
    /* Let's do some checking and ensure that the user's email address or username
    does not exist in the database */

    $sql_email_check mysql_query("SELECT email_address FROM users
                WHERE email_address='$email_address'"
    );
    $sql_username_check mysql_query("SELECT username FROM users
                WHERE username='$username'"
    );

    $email_check mysql_num_rows($sql_email_check);
    $username_check mysql_num_rows($sql_username_check);

    if((
    $email_check 0) || ($username_check 0)){
        echo 
    "Please fix the following errors: <br />";
        if(
    $email_check 0){
            echo 
    "<strong>Your email address has already been used by another member
            in our database. Please submit a different Email address!<br />"
    ;
            unset(
    $email_address);
        }
        if(
    $username_check 0){
            echo 
    "The username you have selected has already been used by another member
             in our database. Please choose a different Username!<br />"
    ;
            unset(
    $username);
        }

    if(
    $PASSWORD != $password_re){
    echo 
    "Your passwords did not match";
    }
        include 
    'join_form.html'// Show the form again!
        
    exit();  // exit the script so that we do not create this account!
    }
    I did something wrong but I cannot find it. here is the error message I recieve.

    Warning: main(db.php): failed to open stream: No such file or directory in /home/virtual/site103/fst/var/www/html/register.php on line 3

    Warning: main(): Failed opening 'db.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site103/fst/var/www/html/register.php on line 3

    Warning: mysql_query(): Access denied for user: 'apache@localhost' (Using password: NO) in /home/virtual/site103/fst/var/www/html/register.php on line 55

    Warning: mysql_query(): A link to the server could not be established in /home/virtual/site103/fst/var/www/html/register.php on line 55

    Warning: mysql_query(): Access denied for user: 'apache@localhost' (Using password: NO) in /home/virtual/site103/fst/var/www/html/register.php on line 57

    Warning: mysql_query(): A link to the server could not be established in /home/virtual/site103/fst/var/www/html/register.php on line 57

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site103/fst/var/www/html/register.php on line 59

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site103/fst/var/www/html/register.php on line 60

    It says it failed to open the db and I do not know why. Do I have to change "db" to the name of my database or the table I made?

    thanks.

  • #2
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the problem appears to be with db.php. Is the db.php file in the same directory as your login script? are the permissions correct? (i believe 0755 should do it)

    it also looks like you ca'nt login in to your database server. make sure your server address, username, and password are correct.

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes I know I finally figured it out....

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    One more question

    Well everything is running smooth with this except one thing.


    PHP Code:
    $sql_email_check mysql_query("SELECT email_address FROM users
               WHERE email_address='$email_address'"
    );
    $sql_username_check mysql_query("SELECT username FROM users
               WHERE username='$username'"
    );

    $email_check mysql_num_rows($sql_email_check);
    $username_check mysql_num_rows($sql_username_check);

    if((
    $email_check 0) || ($username_check 0)){
       echo 
    "Please fix the following errors: <br />";
       if(
    $email_check 0){
           echo 
    "<strong>Your email address has already been used by another member
           in our database. Please submit a different Email address!<br />"
    ;
           unset(
    $email_address);
       }
       if(
    $username_check 0){
           echo 
    "The username you have selected has already been used by another member
            in our database. Please choose a different Username!<br />"
    ;
           unset(
    $username);
       }

    if(
    $PASSWORD != $password_re){
    echo 
    "Your passwords did not match";
    }
       include 
    'join_form.html'// Show the form again!
       
    exit();  // exit the script so that we do not create this account! 

    For some starnge reason I can enter the same emaila ddress as many times as I want (Which I do not want) but I can only enter a user name once (*which I also want)

    What did I do wrong?

    ALSO
    Whenever I type in different passwordsit comes up with a window asking if I want to change a password for a user...then just submits the info without an error saying that they are differnt and they shgould be changed.


  •  

    Posting Permissions

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