Results 1 to 3 of 3

Thread: Login script PHP

  1. #1
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Login script PHP

    http://www.phpeasystep.com/phptu/6.html

    Hello,

    Could any help with understanding the code of the login script in the above link. Basically its the following section that I need to understand. I'm not entirely sure how to connect to the server and database:

    <?php
    $host="localhost"; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name="test"; // Database name
    $tbl_name="members"; // Table name


    thanks!

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    $host="localhost"; is the database server for your webhost. If localhost doesnt work, it might be something like "db1.webhost.com". CHeck in your Control Panel if unsure.
    $username=""; is the username you use to log into your databases/phpMyAdmin panel - it might use your accountname as a prefix, such as "matt_dbuser". This might also be the name of the database too.
    $password=""; Is the password you setup when creating your database via your webhost.
    $db_name="test"; is the name of the database you created with your webhost - might be the same as the "$username" value. You need to set this up before you start connection with the script in the tutorial.

    Hope that helps

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Connecting to MySQL should be very easy. But it's often hard because you don't know the correct information from the host. It's also hard because if you don't know this information, you can't test the code to begin to understand it.
    So my suggestion is that you look up the "connect to mysql" on your host's website. They usually have examples.

    Many hosts have unpredictable mysql server names, so you won't ever get it to work unless you know that.

    Once you have the correct info, just fill it in like you have.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •