Hi all. i have a dilemna question here. i have created an access database with the username and password tables. I have the ODBC connection which linked PHP to Access. I have created a PHP login form using Dreamweaver:

<form method="post" action="process.php">
Username
<input type="text" name="user" />
<br />
Password
<input type="password" name="pass" />
<br />
<input type="submit" name="submit" value="Login" />
</form>

Now i want to be able to login using from via getting the details from the access database. Somebody said to me to use process.php:
<?
//get variables from form
$user = $GET['user'];
$pass = $
GET['pass'];

How do i use this?
After logging in, the user should be redirected to a website (this should be done using javascript client side checking). Also the login should be able to cope with users forgetting thier passwords and should be able to perform server side checking. Does anyone know i to go about this? Thanks in advance

    When the user hits the submit button he automatically goes to process.php (see <form action="process.php")

    Now in process.php you can do the following:
    connect to your database
    check if user-password are correct
    if correct display the page as intended for logged in users
    if uncorrect display an error that informs the user alon with some links where he can recover his password

    some more, you will log the user in after the namw/pw check is ok, most likely through cookies or sessions

      thanx, i am a newbie here so please can u give me an example of how to use process php? i am using an access database and i have the odbc connection

        I cant give you the correct syntax how to use the access-db since i only worked with mysql before.
        But as far as i know access is also accepting sql-statements...

        Just have a look into the odbc-connections how to do queries and how to handle the results.

        in php its then simple if-then

        if ($password=="ok"){ /display this html text/ }
        else{/display wrong password and password-recovery/}

        on how to do it excactly have a look into controlstructures in the php-manual, it isnt that hard 😉

        [edit]btw, to get a hang of it you can download a free login script which some websites offer, but only use it for learning since copy&paste hardly works[/edit]

          Hi tdomega, please help me out here. i dont know if this is the right way to do the process.php. this is what i have in my script
          The first line connects to the access odbc
          <?
          $odbc = odbc_connect ('PHP Login', 'root', '') or die( "Could Not Connect to ODBC Database!" );
          ?>
          <?
          //get variables from login screen.mdb
          $user = $POST['Rambo'];
          $pass = $
          POST['alphadelta'];
          $sql = "SELECT * FROM login screen WHERE username_column = 'Rambo" . $POST['username'] . "' AND password_column = 'alphadelta" . $POST['password'] . "'"
          ?>

          please can you show me a sample process.php script and how to verify the login details are correct. Also how do i use the php header for redirecting to another website? thanx in advance

            
            ok, cant help you on the odbc part though...
            
            <?php
            //get variables from login screen.mdb
            $sql = "SELECT * FROM TABLE WHERE username_column = '" .  $_POST['username'] . "' AND password_column = '" . $_POST['password'];
            //username and password are the names of the input fields on the last page
            
            $result = odbc_query($sql); //or something like that
            //here i dont know how to get the actual resulting columns out of that $result, see odbc
            //for now lets just pretend $result is an array and is false if there is no row that corresponds to your query
            
            if ($result!=false)
            { //yes the user logged in switch to another page
            //set cookies or whatever you need here
            header("Location: http://www.mypage.com/loggedin.php?user=".$result["$id"]); //what you need here, but take this to a minimum
            exit; // to make sure that the script is not further executed
            }
            else
            {//the user provided wrong user/pw-pair
            header("Location: http://www.mypage.com/error.php");//display password recovery etc. on this page
            exit;
            }
            
            ?>
            

              thanx matey it worked. i found out the odbc stuff. going to bed now:o

                Write a Reply...