Iedere keer krijg ik de melding "couldn't select the database, heb ik alle instellingen goed staan volgens jullie of moet ik nog iets veranderen, of ligt t aan lycos mischien?, de database heb k correct aangemaakt.
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="login2.php">
Username: <input type="text" name="username" size="20">
Password: <input type="password" name="password" size="20">
<input type="submit" value="Submit" name="login>
INSERT INTO users (username, password) VALUES (‘someUser’, md5(‘somePass’));
</form>
</body>
</html>
En hier Login2.php
<?PHP
if (!isset($username) || !isset($password)) {
header( "Location: http://www.yourdomain/login.htm" );
}
elseif (empty($username) || empty($password)) {
header( "Location: http://www.yourdomain/login.htm" );
}
else{
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$dbHost = "localhost";
$dbUser = "riseandshine32";
$dbDatabase = "riseandshine32_nl_db";
$db = mysql_connect ("localhost", "riseandshine32", "")or die ("Error connecting to database.");
mysql_select_db("$riseandshine32_nl_db", $db) or die ("Couldn't select the database.");
$result=mysql_query("select * from users where username='$user' AND password='$pass'", $db);
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
session_start();
session_register('username');
echo 'Success!';
header( "Location: checkLogin2.php" );
}
}
else {
echo 'Incorrect login name or password. Please try again.';
}
}
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="login2.php">
Username: <input type="text" name="username" size="20">
Password: <input type="password" name="password" size="20">
<input type="submit" value="Submit" name="login>
INSERT INTO users (username, password) VALUES (‘someUser’, md5(‘somePass’));
</form>
</body>
</html>
En hier Login2.php
<?PHP
if (!isset($username) || !isset($password)) {
header( "Location: http://www.yourdomain/login.htm" );
}
elseif (empty($username) || empty($password)) {
header( "Location: http://www.yourdomain/login.htm" );
}
else{
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$dbHost = "localhost";
$dbUser = "riseandshine32";
$dbDatabase = "riseandshine32_nl_db";
$db = mysql_connect ("localhost", "riseandshine32", "")or die ("Error connecting to database.");
mysql_select_db("$riseandshine32_nl_db", $db) or die ("Couldn't select the database.");
$result=mysql_query("select * from users where username='$user' AND password='$pass'", $db);
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
session_start();
session_register('username');
echo 'Success!';
header( "Location: checkLogin2.php" );
}
}
else {
echo 'Incorrect login name or password. Please try again.';
}
}
?>