PDA

View Full Version : Tutorial



Death12652
05-21-2010, 12:57 AM
I wouldn't mind a tutorial on creating a member section to your website? One that is in SRL not the others. I tend to understand SRL tutorials better than others. Or if anyone wants to make the scripts for a member section to ones website with information on what to change per users website that would be nice too :)

i luffs yeww
05-21-2010, 01:35 AM
Wait what?

Death12652
05-21-2010, 01:40 AM
You know how you sign in to other websites (Not a Forums) a member section to a website to get into other pages of the website. That would be nice. You would have to use MySQL and HTML or PHP or Both. That's what I mean.

Dgby714
05-21-2010, 01:43 AM
It can be made in PHP+SQL or just PHP or just a .htaccess file!

PHP+SQL Guide: http://www.phpeasystep.com/phptu/6.html

PHP Guide: http://www.phpnerds.com/article/using-cookies-in-php/2

.htaccess Guide: http://www.javascriptkit.com/howto/htaccess3.shtml

Death12652
05-21-2010, 03:00 AM
Thanks I will look into it.

Scaper
05-22-2010, 12:41 AM
what forum software are you using?

Death12652
05-22-2010, 05:41 AM
I don't want to use it for forums. I want it for the actual site?

Frement
05-22-2010, 08:55 AM
Well, first thing is the form, it can be like this:

<form method="post" action="login.php">
<input type="text" name="username" value="Username" />
<input type="password" name="password" value="Password" />
<input type="submit" value="Login" name="Submit" />
</form>

Now what everything means:

<form method="post" action="login.php">
"method" = is a method what the form uses to pass on the variables, best to use post always.
"action" = the file that the form passes the variables to.

<input type="text" name="username" value="Username" />
"type" = text, its just plain text :)
"name" = is the name of the variable that is passed on, and in PHP we can access it like this:

$_POST["username"]
"value" = this is the text that is the default text in the forms field.

<input type="password" name="password" value="Password" />
Same goes for here, except the type is "password" it just shows on the form like: ****** instead of plain text, but it sends it just like plain text :)

Now for the PHP part.
index.php

<?php

session_start();

?>
This is the index.php.<br />
<?php

if (strlen($_SESSION["loggedin"]) > 1) {
echo "<br />Welcome, ".$_SESSION["loggedin"]."!";
} else {
echo '<br />Please login:<br />
<form method="post" action="login.php">
<input type="text" name="username" id="username" maxlength="30" value="Username" />
<input type="password" name="password" id="password" maxlength="30" value="Password" />
<input type="submit" value="Kirjaudu" name="Submit" />
</form>';
}

?>
login.php

<?php

session_start();

if (isset($_POST["username"], $_POST["password"]) && strlen($_POST["username"]) > 1 && strlen($_POST["password"]) > 1) {
$username = $_POST["username"];
$password = md5($_POST["password"]);
$account["test"] = "098f6bcd4621d373cade4e832627b4f6";
$account["test2"] = "ad0234829205b9033196ba818f7a872b";
$account["test3"] = "8ad8757baa8564dc136c1e07507f4a98";
if ($password == $account[$username]) {
$_SESSION["loggedin"] = $username;
header("Location: index.php");
} else {
header("Location: error.php");
}
} else {
header("Location: error.php");
}

?>
error.php

There has been an error with your login.

I dont have time to explain the whole PHP part. But its pretty easy to understand. Just string lengths, arrays and if..then sentences.

I put the files on my host also: http://www.frement.net/srl/death12652/index.php

Death12652
05-22-2010, 02:32 PM
Thanks that helps a lot.

Frement
05-22-2010, 02:42 PM
Thanks that helps a lot.

That it an easy way without a database.