Hey,
Ik ben er eindelijk achter hoe ik een goede inlog script kan maken, in ieder geval dat dacht ik, wat nu doet hij het niet.
Maar hier is het script:
[code="php"]<?php
$send = $_POST['send'] ;
if($send == 'yes')
{
$username = $_POST['username'] ;
$password = md5($_POST['password']) ;
//connection
include('confdata.php') ;
$result = mysql_query("SELECT username, pass FROM users WHERE username='".$username."'") ;
$aantal = mysql_num_rows($result) ;
$login = mysql_fetch_object($result) ;
if($aantal == '0')
{
echo 'The user is incorrect' ;
}
elseif($password != $login->pass)
{
echo 'the pw is incorrect' ;
}
else
{
echo 'Welcome'.$username ;
}
}
?>[/code]
HTML
[code="html"]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="script.php">
<div align="center">
<p><strong>Login </strong></p>
<table width="200" border="0" cellspacing="3" cellpadding="3">
<tr>
<td>Username</td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" id="password" /></td>
</tr>
<tr>
<td><input name="send" type="hidden" id="send" value="yes" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name="Login" type="submit" id="Login" value="Login" />
<input name="Reset" type="reset" id="Reset" value="Reset" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>[/code]
Ik krijg namelijk de hele tijd de melding:
the pw is incorrect