+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Make Login Page

  1. #1
    sweet92 is offline x10Hosting Member sweet92 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    United Kingdom
    Posts
    12

    Unhappy Make Login Page

    could somebody help me, i want to make a login page for my site but i dont know where to start, im using dreamweaver to build this login page, i know there has to be database and the page checks the details against this database but how do you create and add data to this database and get the login page to work

  2. #2
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: Make Login Page

    Oh FFS learn to google.

    Google'd for make login page and the First - *FIRST* - link was http://www.adesdesign.net/php/tutori...cure_login.php, which is exactly the tool you are using for the problem you have.

    I facepalmed so hard I gave myself a concussion.
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  3. #3
    sweet92 is offline x10Hosting Member sweet92 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    United Kingdom
    Posts
    12

    Re: Make Login Page

    well sorry! theres no need to be rude and btw i already DO know how to google im not thick!
    also i have already tried a tutorial it didnt work so i thought id ask here instead
    Last edited by sweet92; 10-07-2008 at 09:46 AM.

  4. #4
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Re: Make Login Page

    Just tell us what didn't work and we'll work from there. Post the code you already have so we can see what needs to be added or changed.

  5. #5
    sweet92 is offline x10Hosting Member sweet92 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    United Kingdom
    Posts
    12

    Re: Make Login Page

    firstly i made the file loginpage.php , not sure if the code is important for this bit but ill add just in case
    <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form name="form1" method="post" action="checklogin.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td colspan="3"><strong>Member Login </strong></td>
    </tr>
    <tr>
    <td width="78">Username</td>
    <td width="6">:</td>
    <td width="294"><input name="myusername" type="text" id="myusername"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>:</td>
    <td><input name="mypassword" type="text" id="mypassword"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>

    then i tried to make checklogin.php, i think this is where i went wrong and i got confused, the code i tried to use was this, the code is from the tutorial i tried and failed on

    <?php
    $host="fashion.x10hosting"; // Host name
    $username=""; // Mysql username <<Unsure about this bit
    $password=""; // Mysql password
    $db_name="Accountinfo"; // Database name
    $tbl_name=""; // Table name

    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];

    // To protect MySQL injection (more detail about MySQL injection)
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row

    if($count==1){
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword");
    header("location:login_success.php");
    }
    else {
    echo "Wrong Username or Password";
    }
    ?>

    and i didnt really get much further than that i have made the database and loginsuccess.php, im pretty new to scripts so not very sure about if i need to edit any bits

  6. #6
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Make Login Page

    Quote Originally Posted by sweet92 View Post
    firstly i made the file loginpage.php , not sure if the code is important for this bit but ill add just in case
    no problems with the form.
    Quote Originally Posted by sweet92 View Post

    then i tried to make checklogin.php
    Why not keep the code in the same page as the form?
    Quote Originally Posted by sweet92 View Post
    PHP Code:
    $username=""// Mysql username <<Unsure about this bit 
    username is usually a mixture of your main account name and your db username (yourmainusername_databaseusername)

    Quote Originally Posted by sweet92 View Post
    PHP Code:
    // Connect to server and select databse.
    mysql_connect("$host""$username""$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB"); 
    Try to use the MySQL error function wherever possible - it will help you loads...

    PHP Code:
    or die(mysql_error()) 
    Try getting the connection first...

    There are a few people on here that will try to help as much as possible (for some strange reason! :nuts

  7. #7
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    Re: Make Login Page

    freecrm has already clarified most of the things required to make a login page.

    The first thing that you need to do is create a Login screen. You can do this either using the design view or the code view of dreamweaver. Once you have this, then you are ready to add in the PHP code needed to make the login work.

    The first thing to do is to make a database that is going to contain the login information. This is done by running SQL commands in MySQL under the cPanel belonging to your account.

    Code:
    CREATE TABLE users (ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(60), password VARCHAR(60))
    This is only a basic SQL statement that you could use. If you want extra fields on your registration form then you need to add extra fields into your database.

    The next part of the build is to build a registration form to enable you to enter information into the database, that you can then use to login with.

    The only fields you are going to need are a username one and a password field.

    Code:
    <input type="text" name="user" />
    <br />
    <input type="password" name="password" />
    <br />
    <input type="button" name="submit" value="Register!" />
    That code above creates a simple basic register form. You need to include the registration code that you are going to add in a seperate page.

    register.php

    First the connection:
    PHP Code:
    $db[user] = "cPanel username here";
    $db[pass] = "cpanel password here";
    $db[host] = "localhost";
    $db[dbname] = "name of database. Normally begins with your cPanel name";

    $db_conn mysql_connect("$db[host]""$db[user]""$db[pass]")or die("cannot connect"); 

    $db_select mysql_select_db("$db[dbname]")or die("cannot select DB"); 
    That creates the connection to the database and then shows any erros if there are any when you are connecting to your database.

    Now you have to add an insert statement into the register.php file in order to get the information that has been entered into the form into the database.

    Now I aint very good with PHP so you shall have to serach google onto how to insert statements with sql using variables.

    You can add extra features to the register.php file in order to make the registration more secure, such as md5 hash encryption. This is really useful on things such as passwords etc.

    In the login page you need to add code to match the the entered info with that in the database!

    Again me not being good with PHP and a it being a long time since I created something like this, a lot of google research will be needed when creating this.

    Post back if you need more help and we shall see what we can do!
    Regards,
    Zenax

  8. #8
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Make Login Page

    then to register username and password, I'd say to use
    PHP Code:
    $_SESSION['user']['username'] = $username;
    $_SESSION['user']['password'] = $password
    You might as well consider encrypting your passwords for added security.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  9. #9
    natsuki's Avatar
    natsuki is offline x10 Sophmore natsuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    112

    Re: Make Login Page

    Zenax found the problem, you should use 'localhost' as hostname (if both database and files are on x10hosting).

  10. #10
    sweet92 is offline x10Hosting Member sweet92 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    United Kingdom
    Posts
    12

    Re: Make Login Page

    thanks alot for helping me but when i put this on my site i get an warning saying it cant connect to the database have also created a bulletin board along with login page that has an warning also along the same lines, do i need to update my php to get this to work? im on the basic php at the moment.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. page login help
    By delon in forum Programming Help
    Replies: 2
    Last Post: 05-23-2008, 04:16 AM
  2. Can't login to x10 home page or cpanel
    By pcadmin in forum Free Hosting
    Replies: 2
    Last Post: 05-01-2008, 01:11 PM
  3. Replies: 1
    Last Post: 03-06-2008, 06:15 AM
  4. Replies: 0
    Last Post: 03-05-2008, 08:30 PM
  5. Page gone, login to ftp bounces
    By musoc in forum Free Hosting
    Replies: 1
    Last Post: 11-19-2007, 06:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers