I have three pages
First page = login.php << it has only the form to login
Second page = login_pro.php << to validate and check if the user is registered
Third page = mypage.php << a page for the user where s/he can update his information
where exactly should I put the code and where should I use the session_start(), is it before the <html> or after the <body> ???
Here is the code that i had but i don't know where should i put it ecaxtly and in which page
Code: Select all
<?php
session_start();
//You can relpace $s != session_id() with !session_is_registered('username') or !$_SESSION['username']
if($s != session_id() || !$action || $action == "") {
if(!$_POST['username']) {
$username = $_SESSION['username'];
$password = $_SESSION['password'];
}
else {
$username = $_POST['username'];
$password = $_POST['password'];
}
@ $db = mysql_connect("localhost", "root", "") or die("Error: Could not connect to database.");
mysql_select_db("Tarjama");
$login_query = "SELECT * FROM customer WHERE Username='$username' AND Password='$password'";
$login_result = mysql_query($login_query);
$check = mysql_num_rows($login_result);
if($check > 0) {
if($error) {
echo "<b>You have the following errors:</b><br>". $error;
$action = "not_logged";
}
else {
while($row = mysql_fetch_array($login_result)) {
session_register('username');
$_SESSION['username'] = $row['Username'];
session_register('password');
$_SESSION['password'] = $row['Password'];
session_register('user_page');
$_SESSION['user_page'] = $row['User_Page'];
}
$action = "show_user_page";
}
}
else {
echo "<strong>Logon Denied</strong> Invalid username OR password.";
$action = "not_logged";
}
}
if($action == "not_logged") {
//echo your login page here
}
if($action == "show_user_page") {
//This is just an example path_to_pages/user_dir/user_page
include("uploads/".$_SESSION['username']."/".$_SESSION['user_page'])
}
?>I really need someone to help me..
Your help is appreciated