Ok now what do i do

Started by
7 comments, last by Toolmaker 19 years, 9 months ago
ok i have the code for the php for a login but what do i do with it?
Advertisement
Include it on your page?
-----------------SloGameDev.net | My homepageQ:What does a derived class in C# tell to it's parent?A:All your base are belong to us!
Do you have any PHP/programming knowledge? It's obvious you need to work out some workflow.

I did it like this:
$Action = GetPostField("action", null); // Custom made function switch ($Action){    case null:        ShowLoginForm();        break;    case "login":        $Username = GetPostField("username", null);        $Password = GetPostField("password", null);        // Check username/password stored in db        if (CheckLogin($Username, $Password) == TRUE)        {            // Store cookie for auto login            StoreCookie($Username, $Password);            // Forward to mainpage            header("location: index.php");        }        else        {            ErrorMessage("Invalid username/password");            ShowLoginForm();        }        break;}


Well, sort of... I have no idea if it works, but my login code looked something like that. Consider using sessions though.

Toolmaker

On this subject, does anyone know of any place where they have a beginner's PHP tutorial on logins, etc (for someone who can already program in C++)?
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
ok but do i have to make a dialoge box for them to type in and if so how?
i have no php or programing knoledge i just no basic java script and i know html @ toolmaker
Give me 30 minutes, I am working out an example for you.

Toolmaker

cant you use the .htaccess file for a login dialog? or isnt it supported on you http-server? just wondering...


T2k
Ok, I wrote an HTML page that contains a "login dialog" and a Submit button. When you call ShowLoginForm(), you should output this code in that function.

When you click "Submit", it will call "login.php?action=login".

<center>    Please login<br><br>    <form name="login" action="login.php" method="post">        <table border="0">            <tr>                <td width="100px">Username</td>                <td width="250px"><input type="text" size="30" name="username"/></td>            </tr>            <tr>                <td width="100px">Password</td>                <td width="250px"><input type="password" size="30" name="password"/></td>            </tr>            <tr>                <td colspan="2" align="center">                    <input type="submit" text="login">                </td>            </tr>        </table>    </form></center>


Because you know nothing about PHP, I suggest you go to the link below and follow the tutorial.
http://www.w3schools.com/php/default.asp

Toolmaker

This topic is closed to new replies.

Advertisement