Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 16 1 2 3 11 ... LastLast
Results 1 to 10 of 151
  1. #1
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Now, as you all probably know from my recent posts, I am trying to get the hang of PHP/MySQL login systems. I am trying to create one and my problem is that it won't connect to the database to add the data I entered. Here's the script I am using for register.php:

    PHP Code:
    <?PHP
    //Connect to database
    $dbh=mysql_connect ("localhost""rednerve_""mypass") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("rednerve_login"); 
     
    $name $_POST['name'];
    $email $_POST['email']; 
    $username $_POST['username'];
    $password md5($_POST['password']);
    // lets check to see if the username already exists
    $checkuser mysql_query("SELECT username FROM users WHERE username='$username'"); 
    $username_exist mysql_num_rows($checkuser);
    if(
    $username_exist 0){
    echo 
    "I'm sorry but the username you specified has already been taken. Please pick another one.";
    unset(
    $username);
    include 
    'register.html';
    exit();

    // lf no errors present with the username
    // use a query to insert the data into the database.
    $query "INSERT INTO users (name, email, username, password)
    VALUES('
    $name', '$email', '$username', '$password')";
    mysql_query($query) or die(mysql_error());
    mysql_close();
    echo 
    "You have successfully Registered";
    // mail user their information
    $yoursite www.blahblah.com;
    $webmaster ‘yourname’;
    $youremail ‘youremail’;
    $subject "You have successfully registered at $yoursite...";
    $message "Dear $name, you are now registered at our web site. 
    To login, simply go to our web page and enter in the following details in the login form:
    Username: 
    $username
    Password: 
    $password
     
    Please print this information out and store it for future reference.
     
    Thanks,
    $webmaster";
     
    mail($email$subject$message"From: $yoursite <$youremail>\nX-Mailer:PHP/" phpversion());
    echo 
    "Your information has been mailed to your email address.";
    ?>
    My password is not actually "mypass", but that's just an example. Now, when I try to run that script (with a HTML form with that php form as the action), I get the following error:

    Warning: mysql_connect(): Access denied for user: 'rednerve_@localhost' (Using password: YES) in /home/rednerve/public_html/register.php on line 4
    I cannot connect to the database because: Access denied for user: 'rednerve_@localhost' (Using password: YES)
    I have made the database and added the user to it on my hosting control panel and still, to no avail.

    Do you have to upload the data in the database folder from your comp to server? That is the only thing I have not done.

    I hope you can understand my problem, I know it is confusing, please try and help me, I really want to get these login systems down! Thanks in advance, will7.
    Rednerve
    Creative Freelance Design

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    What version of MySQL is the server running?
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    MySQL Version: 4.0.22-standard
    Rednerve
    Creative Freelance Design

  5. #4
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    There's a quote mark missing after your password 'mypass' in your supplied code. (that may of course only be a typo here, but just in case. There are members who have made mistakes like that previously).

    Have no time to look deeper into it right now.
    S. Rosland

  6. #5
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Just a typo on here, it's there in the actual code. Any more ideas, anyone?
    Rednerve
    Creative Freelance Design

  7. #6
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    Supposed to be "rednerve_" for the login? _ supposed to be there?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  8. #7
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Yeah, it says on my CPanel that that's the username.
    Rednerve
    Creative Freelance Design

  9. #8
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    in CPanel, is the username attached with permissions to the database?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  10. #9
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    If you have Cpanel, click the mysql link and see what it lists as username/usernames (you can have several).

    "rednerve_" looks like a prefix. Is that all that's listed there?

    As an example, if I have a domain on a server, and my username to access that area (CPanel, public_html, etc) is "gluteus", then all my MySQL created usernames will start with the prefix "gluteus_".

    If I for example add a new MySQL user (in CPanel) called "maximus", the name listed in the user accounts, will be "gluteus_maximus".

    So, in short, if you add a new user to your MySQL DB called "will7", then to log in as "will7", you should write "rednerve_will7".

    If there are no users listed, try to add a new one, and try to write your log-in script using the prefix as listed in the example.
    S. Rosland

  11. #10
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Users in login
    rednerve_ (Privileges: ALL PRIVILEGES)

    And yes, rednerve_ is all that is listed there.

    Also, on CPanel, it actually says that my MySQL connection string should be:

    PHP Code:
    dbh=mysql_connect ("****""******_""<PASSWORD HERE>") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("*****"); 
    </I>

    Obviously I replaced <PASSWORD HERE> with my password.
    Rednerve
    Creative Freelance Design


Page 1 of 16 1 2 3 11 ... LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:52 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com