Here is my PHP code, I see no error :
PHP Code:
<?php
if (isset($_POST['inscription']) && $_POST['inscription'] == 'Inscription') {
if ((isset($_POST['login']) && !empty($_POST['login'])) && (isset($_POST['pass']) && !empty($_POST['pass'])) && (isset($_POST['pass_confirm']) && !empty($_POST['pass_confirm']))) {
if ($_POST['pass'] != $_POST['pass_confirm']) {
$error = 'The 2 passwords are different.';
}
else {
$base = mysql_connect("localhost", "root", "");
mysql_select_db("espacemember");
$sql = 'SELECT id FROM member WHERE login="'.mysql_escape_string($_POST['login']).'"';
$req = mysql_query($sql) or die('SQL Error!<br />'.$sql.'<br />'.mysql_error());
$nb = mysql_num_rows($req);
if ($nb == 0) {
$sql = 'INSERT INTO member VALUES("", "'.mysql_escape_string($_POST['login']).'", "'.md5(mysql_escape_string($_POST['pass'])).'")';
mysql_query($sql) or die('SQL Error!'.$sql.'<br />'.mysql_error());
$id = mysql_insert_id();
session_start();
$_SESSION['login'] = $_POST['login'];
$_SESSION['id'] = $id;
header('Location: member.php');
exit();
}
else {
$error = 'A member already has this login.';
}
}
}
else {
$error = 'At least one field is empty.';
}
}
?>
<h4>Toulouse Athletic Club Tennis Table</h4><br />
<form action="inscription.php" method="post">
Login : <input type="text" name="login" value="<?php if (isset($_POST['login'])) echo stripslashes(htmlentities(trim($_POST['login']))); ?>"><br />
Password : <input type="password" name="pass" value="<?php if (isset($_POST['pass'])) echo stripslashes(htmlentities(trim($_POST['pass']))); ?>"><br />
Confirmation of password : <input type="password" name="pass_confirm" value="<?php if (isset($_POST['pass_confirm'])) echo stripslashes(htmlentities(trim($_POST['pass_confirm']))); ?>"><br />
<input type="submit" name="inscription" value="Inscription">
</form>
<?php
if (isset($error)) echo '<br />',$error;
?></p>
So when we finished the registration must be sent directly member.php
its just might be there:
PHP Code:
$_SESSION['id'] = $id;
header('Location: member.php');
exit();
Bookmarks