i organising files appropriate folders , problem has arisen. before changing code organise files worked. whenever try log in, instead of redirecting 'staff/staff.php', redirects 'staff/index.php'.
the code follow:
<?php session_start(); include("connectdb.php"); //if form has been submitted if (isset($_post['submitted'])){ //get information out of or post depending on form $username = $_post['username']; $password = $_post['password']; global $db; //sanitise inputs! $safe_username = $db->quote($username); //run query user associated username $query = "select * user username = $safe_username"; $result = $db->query($query); $firstrow = $result->fetch(); //get first row if (!empty($firstrow)) { //check passwords, if correct add session info , redirect $hashed_password = md5($password); if ($firstrow['password'] == $hashed_password){ $_session['id'] = $firstrow['userid']; $_session['username'] = $firstrow['username']; $_session['fname'] = $firstrow['first_name']; $_session['lname'] = $firstrow['last_name']; $_session['staff'] = $firstrow['staff']; if($firstrow['staff'] == 1) { header("location:staff/staff.php"); exit(); } else { //echo "success!"; header("location:customer/customer.php"); exit(); } } else { echo "<h1>error logging in, password not match</h1>"; } } else { //else display error echo "<h1>error logging in, username not found</h1>"; } } ?> <html> <head> <link rel="stylesheet" type="text/css" href="css/theme.css"> </head> <body> <h1 class="register-title">aston animal sanctuary</h1> <div class="register"> <!--<form method="link" action="staff.php"> <input type="submit" value="staff login"> </form>--> <form action="index.php" method="post"> <input type="text" class="register-input" name="username" placeholder="username"> <input type="password" class="register-input" name="password" placeholder="password"> <input type="submit" value="login" class="register-button"> <input type="hidden" name="submitted" value="true" /> </form> <form method="link" action="register.php"> <input class="register-button" type="submit" name="register" value="register"> </form> <div> <!--<a href="test1.php" class="button">test</a>--> </body> </html> <?php include('view/footer.html'); ?>
is header problem?
edit
the same thing happens logout file. redirects 'staff/logout.php' instead of '../logout.php'. worked before started organising files.
the code logout.php:
<?php session_start(); //get previous session info session_destroy(); //destroy header("location: ../index.php"); //redirect start ?>
have tried:
header("location: ./staff/staff.php");
and:
header("location: ./customer/customer.php");
Comments
Post a Comment