diff --git a/login/login.php b/login/login.php index ae396437253f914d025eb916188050b2f19e5966..595bfe03d17dc467ad158ec1d4f7c6873a463c80 100755 --- a/login/login.php +++ b/login/login.php @@ -1,4 +1,5 @@ <?php + session_start(); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) { include '../database/dbconnect.php'; @@ -17,7 +18,6 @@ if($user == $dbusername && $pass == $dbpassword) { - session_start(); $_SESSION['user'] = $user; header("Location: ../order/order.php"); } diff --git a/login/logout.php b/login/logout.php new file mode 100644 index 0000000000000000000000000000000000000000..da7dd4cfa2c5ad8c3aa1f51ef99abc13adef9a73 --- /dev/null +++ b/login/logout.php @@ -0,0 +1,6 @@ +<?php + session_start(); + session_unset(); + session_destroy(); + header("Location: ../login/login.html"); +?> diff --git a/login/sign_up.php b/login/sign_up.php index fc240892cafd089e82e4797840e70f2cbfc1cd4e..2ac634cc9c28cdde376a68464b5df7ea955c9ed3 100644 --- a/login/sign_up.php +++ b/login/sign_up.php @@ -1,4 +1,5 @@ <?php + session_start(); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!empty($_POST['full_name']) && !empty($_POST['username']) && @@ -7,6 +8,7 @@ !empty($_POST['confirm_password']) && !empty($_POST['user_phone'])) { + session_start(); include '../database/dbconnect.php'; $fullname = $_POST['full_name']; $username = $_POST['username']; @@ -26,7 +28,6 @@ $query = mysql_query("INSERT INTO user (name,email,phone,username,password,status,pict) VALUES ('$fullname', '$email', '$phone', '$username', '$password', '$status',DEFAULT)") or die(mysql_error()); if($query) { - session_start(); $_SESSION['user'] = $username; if ($status == "customer") { header("Location: ../order/order.php"); diff --git a/profile_page/profile.php b/profile_page/profile.php index 150ea374cd3e6602e7ad1b3ea61ecf29cac0d28f..eaca70f42d70fe4be19674e66093d6c760762d89 100755 --- a/profile_page/profile.php +++ b/profile_page/profile.php @@ -1,4 +1,6 @@ -<?php //if (!isset($_SESSION['user'])) die("<br /><br />You must be logged in to view this page");?> +<?php + session_start(); +?> <html> <head> <title>U Wanna Call Me Beibh?</title> @@ -24,7 +26,8 @@ </div> <?php include '../database/dbconnect.php'; - $user = "eHower"; + + $user = $_SESSION['user']; $query=mysql_query("SELECT * FROM user WHERE username='".$user."'") or die(mysql_error()); $numrows=mysql_num_rows($query); @@ -39,9 +42,9 @@ } echo $row['email']."</br>"; echo $row['phone']."</br>"; - /*if (isset($row['pict'])) { + if (isset($row['pict'])) { echo "<script>document.getElementById('profile_pict').src = '../img/default_profile.jpeg'</script>"; - }*/ + } } } mysql_close(); diff --git a/template/header.php b/template/header.php index cf59869662c20df6309d62a7410959121046da53..57dfed508b1e5fd93e81de2382affb46b8f274f8 100644 --- a/template/header.php +++ b/template/header.php @@ -4,7 +4,7 @@ <p>"An ojek for anything you need"</p></br> </div> <div class="greeting"> - <p>Hello, "Eisenhower!"</p> - <p>Logout</p> + <p>Hello, '.'"'.$_SESSION['user'].'"'.'</p> + <p><a href="../login/logout.php">Logout</a></p> </div>'; ?>