Jump to content

graham

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by graham

  1. Wondering if someone could help me out. How do I change my uri from localhost/killerphp/public/index to killerphp/index (the way John has it) In other words, when I echo $_SERVER['REQUEST_URI'] on the index page I would like to get: /index not /killerphp/public/index (this stuff is in the "Dispatching Requests to Multiple Controllers" video) It would make following along with the videos a lot simpler. Any suggestions would be appreciated.
  2. Hi all, I was hoping that someone could point me in the right direction (i'm new to this so go easy on me). I'm writing a very simple login page. I want to make it impossible to for an unauthorised user to enter the members area simply by entering the correct url. This is the members.php code: <?php session_start(); if (!isset($_SESSION['username'])) { header ("Location: my_login_main.html"); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'>http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="my_login_style.css" /> <title>Welcome Member</title> </head> <body> <h1>Welcome to the Members Area!</h1> <?php echo "hello " . $_SESSION['username'] . " you have logged in successfully"; ?> </body> </html> and the username and password gets checked with this php code: <?php session_start(); if (isset($_POST['submit'])) if($_POST['username'] == '' || $_POST['password'] == '') { echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="my_login_style.css" /> <title>Login Main</title> </head> <body> <h1>Login Main</h1><br /> <div class="error">Please fill in both text fields</div><br /> <form action="check_user.php" method="post"> <strong>Username:</strong><input type="text" name="username" /><br /> <strong>Password: </strong><input type="password" name="password" /><br /> <input type="submit" name="submit" value="Submit" /><br /><br /> <a href="create_new_user.php">Create New User</a> </form> </body> </html>'; } else { //connect to database include ("connect.php"); $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; //create query $query = mysql_query("SELECT * FROM users WHERE Username = '$_SESSION[username]' AND Password = '$_SESSION[password]'"); if (mysql_num_rows($query) > 0) { header ("Location: members.php"); } else { echo "Username and password not found"; } } I'm quite sure the solution is obvious but I just can't seem to see it.
×
×
  • Create New...