Sign in to follow this  
Alex3579

Ok now what do i do

Recommended Posts

Toolmaker    967
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

Share this post


Link to post
Share on other sites
red_sodium    216
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++)?

Share this post


Link to post
Share on other sites
T2k    220
cant you use the .htaccess file for a login dialog? or isnt it supported on you http-server? just wondering...


T2k

Share this post


Link to post
Share on other sites
Toolmaker    967
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this