Ik heb hier 2 scripts die ik gebruikt.
Onder het kopje "account" op mijn website moet de gebruiken worden verzonden naar of het inlog scherm, of het account scherm. Dit ligt er natuurlijk aan of de gebruiker is ingelogd. Hier zijn mijn scripts:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Wizzardz</title>
<link rel="stylesheet" type="text/css" href="WizzardzAccount.css">
</head>
<?
if(isset($_POST["Nickname"]) && isset($_POST["Password"])){
require_once('WizzardzCheckuser.php');
$check=CheckUser($_POST["Nickname"],$_POST["Password"]);
if(!$check){
echo "wrong username or password" ;
}
}
if(isset($_SESSION["user"])){
echo "hier komt het gebruiker deel";
}
else{
echo '
Welcome! Before we can move you to the account panel, you must log in. Please enter your username and password below.
<br></br>
<form method="post" action="?page=WizzardzAccount2.php">
<table border="0" id="Table">
<tr>
<td>Nickname:</td>
<td><input type="text" name="Nickname" value=""></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="Password" value=""></td>
</tr>
<tr height="15"></tr>
<tr>
<td><a href="?page=WizzardzForgotpassword.php">Forgot password?</a></td>
<td><a href="?page=WizzardzAccountCreate.php">Create new account?</a></td>
</tr>
</table>
<input type="submit" id="LoginButton" value="Login">
</form>';
}
?>
</html>
--
<?php
function CheckUser($user,$pass){
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="wizzardz"; // Database name
$tbl_name="account"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name");
// To protect MySQL injection (more detail about MySQL injection)
$myusername = mysql_real_escape_string($user);
$mypassword = mysql_real_escape_string($pass);
$sql="SELECT * FROM $tbl_name WHERE Nickname='$myusername' and Password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['user'] = $myusername;
return 1;
}
else {
return 0;
}
}
?>
Met deze scripts laat hij elke keer het deel zien waar hij al is ingelogd.
Iemand een idee?
Bedankt!