Congax
Fledgling Freddie
- Joined
- Aug 18, 2004
- Messages
- 3,231
I need your help 
Making memberlogin system and all that but I just can't seem to get it working. Anyone who can give me a clue on what I'm doing wrong?
Sorry about the dutch //comments but you can ignore them anyway. Any help would be wildly appreciated. Apologies for the long post/code etc
Making memberlogin system and all that but I just can't seem to get it working. Anyone who can give me a clue on what I'm doing wrong?
Code:
REGISTER.PHP
<?php
include "connect.php";
if (isset($_REQUEST["action"])){
switch ($_REQUEST["action"])
{
case "AddUser":
$sql_aanmelding = "INSERT INTO `members` (`naam`, `email`, `password`, `datum`) VALUES (' " . $_POST['naam'] . "', ' ". $_POST['email']. " ', ' ". $_POST['password']. " ', NOW()";
$verzenden = mysql_query($sql_aanmelding);
echo"Hello ".$_POST['naam'].", your application has been succesfully processed. You can now log in.";
break;
}
}
?>
<form name="inloggen" action="register.php" method="post">
<p>Name:
<input type="text" name="naam">
E-mail:
<input type="text" name="email">
Password:
<input type="password" name="password">
<input type="hidden" name="action" value="AddUser">
<input type="submit" name="submit" value="Submit">
</p>
</form>
Code:
HOME.PHP
<?php
include "login.php";
?>
Code:
LOGIN.PHP
<?
include "connect.php";
$sql = "SELECT * FROM `members` WHERE `email` = '".$_POST['email']."'"; //alle gebruikers met het ingevoerde e-mailadres ophalen
$ophalen = mysql_query($sql) or die(mysql_error()); // query uitvoeren
$aantal = mysql_num_rows($ophalen); // aantal records met verstuurd emailadres tellen
if($aantal == 0){
//blijkbaar komt het mailadres niet in de database voor!
echo"<p>Error: No such email in the database</p>";
}else{
//mailadres staat in de database, we gaan verder!
while($record = mysql_fetch_object($ophalen)){
$password_db = $record->password;
}
//password nu vergelijken met ingevoerd password
if($password_db != $_GET['password']){
echo"<p>Error: incorrect password</p>";
}else{
//email staat in database en password klopt, sessie starten!
while($record = mysql_fetch_object($ophalen)){
$id = $record->id;}
echo"<p>You've been succesfully logged in.</p>";
//sessie opstarten
$_SESSION['id-nummer'] = $id;
}
}
?>
<form name="inloggen" method="post">
<h2>Login</h2>
<p>Email:<br /><input type="text" name="email" maxlength="40" /></p>
<p>Password:<br /><input type="password" name="password" maxlength="20" /></p>
<p><input name="cmdlogin" type="submit" id="cmdlogin" value="Login" />
</p>
</p>
<p><input name="Register" type="button" onClick="document.location.href=('register.php')" value="register"></p>
</form>
Sorry about the dutch //comments but you can ignore them anyway. Any help would be wildly appreciated. Apologies for the long post/code etc