Beste,
ik heb een probleem met mijn script.
ik heb een account aangemaakt in mijn database,
maar waneer ik inlog gaat hij nietmeer verder.
Mijn login script
Dan heb ik ook een checklogin.php, en ik denk dat daar de fout zit, maar ik weet niet zeker, en hier het script:
En daar blijft hij steken, maar ik heb dan nog een laatste script, login_succes.php
maar die komt helemaal ni, de pagina blijft ook wit!
En dit was het. als iemand mij kan helpen,
alvast bedankt.
ik heb een probleem met mijn script.
ik heb een account aangemaakt in mijn database,
maar waneer ik inlog gaat hij nietmeer verder.
Mijn login script
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table> Dan heb ik ook een checklogin.php, en ik denk dat daar de fout zit, maar ik weet niet zeker, en hier het script:
[COLOR= #0000BB]<?php
$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"root"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"Mijn wachtwoord"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"DB Naam"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"Table naam"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// Connect to server and select databse.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$host"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$username"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$password"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$db_name"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// username and password sent from form [/COLOR]
[COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]myusername[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mypassword[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #FF8000]// To protect MySQL injection (more detail about MySQL injection)[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM $tbl_name WHERE username=$myusername and password=$mypassword"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// Mysql_num_row is counting table row[/COLOR]
[COLOR= #0000BB]$count[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// If result matched $myusername and $mypassword, table row must be 1 row[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #FF8000]// Register $myusername, $mypassword and redirect to file "login_success.php"[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"myusername"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mypassword"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:login_success.php"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Wrong Username or Password"[/COLOR][COLOR= #007700];
}[/COLOR]
?> En daar blijft hij steken, maar ik heb dan nog een laatste script, login_succes.php
maar die komt helemaal ni, de pagina blijft ook wit!
[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/session_is_registered"]session_is_registered[/URL][COLOR= #007700]([/COLOR]myusername[COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:main_login.php"[/COLOR][COLOR= #007700]);
}[/COLOR]
?>
<html>
<body>
Login Successful,
</body>
</html> En dit was het. als iemand mij kan helpen,
alvast bedankt.



