Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Unanswered: MYSQL -PHP login page?

    Hello!

    I were just asking help if somebody could help me with this problem...
    I would like to create login page before my home page and I would like make it with PHP. Passworw should be asked and confirmed from MySQL dataBase...
    Thank for any help!!!

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: MYSQL -PHP login page?

    Originally posted by t0asinkkonen
    Hello!

    I were just asking help if somebody could help me with this problem...
    I would like to create login page before my home page and I would like make it with PHP. Passworw should be asked and confirmed from MySQL dataBase...
    Thank for any help!!!
    http://www.phpbuilder.com
    http://www.php.net (section mysql in doc)

  3. #3
    Join Date
    Nov 2003
    Posts
    8
    make a config file
    config.php
    PHP Code:
    <?php
    mysql_pconnect
    ("host","name","pass");
    mysql_select_db("dbname");
    ?>
    then your index.php page should contain the log in form

    PHP Code:
    <?php include("config.php"); ?>

    bunch of HTML or what ever you have coded in

    in this bunch you need to have a 
    log in form that looks something like this


    <table cellpadding=0 cellspacing=0 width=50%>
    <form method=post action=login.php>
    <tr><td width="67" with=10>Email:</td>
    <td width="145"><input type=text name=email></td></tr>
    <tr><td with=10>Password:</td><td><input type=password name=pass></td></tr>
    <tr><td colspan=2 align=center><input type=submit value=Login></td></tr></table></form>

    then you need a login page
    PHP Code:
    <?php
    if (!$email || !$pass) {
        include(
    "config.php");
        print 
    "Please fill out all fields.";
        exit;
    }
    include(
    "config");
    $sql mysql_query("select * from dbname where email='$email' and pass='$pass'");
    $logres mysql_num_rows($sql);
    if (
    $logres <= 0) {
        print 
    "Login failed.";
        exit;
    } else {
        
    session_register("email");
        
    session_register("pass");
        print 
    "&nbsp;<br>Welcome back. Please click 
                    <a href=membersonly.php>here</a> to continue.."
    ;
    }
    ?>
    you might consider a register page as well
    you should beable to figure out how to make it after seeing this post and looking at the sites mentioned above
    Last edited by deRusett; 12-02-03 at 07:17.

Posting Permissions

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