SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Password Help

  1. #1
    SitePoint Enthusiast bobbobbobbob's Avatar
    Join Date
    Apr 2004
    Location
    bobbobbobbob
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't appear it can find db.php... is it in the right directory? The errors after that are probably because you don't have a connection (since db.php wasn't found).

  3. #3
    SitePoint Enthusiast bobbobbobbob's Avatar
    Join Date
    Apr 2004
    Location
    bobbobbobbob
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah its wierd......I don't have a db.php.

    The tutorial never said to make one.

    Should I replace it with the table name which is users

    or the database name?

  4. #4
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Los Angeles
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe db.php is probably the MySql database connection script. If so, you would have to make one and call it db.php

  5. #5
    SitePoint Member
    Join Date
    Apr 2004
    Location
    UK
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, was this a tutorial for PEAR? I believe PEAR has a DB.php which should be avaliable on most PHP installs automatically if include_path is set up correctly. Can't see any PEAR connections though.

  6. #6
    SitePoint Guru r2d2's Avatar
    Join Date
    Dec 2003
    Location
    In my van, fool!
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont think it was anything to do with PEAR.

    You do need to write a DB connection script though and save it as db.php.

    Im my case, I just changed the script to include header.php which also creates a db connection.


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
  •