Jump to content

geloo

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

geloo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hallo my problems is something with the session in my script as it redirects even when i logged in can someone help out please.. the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title> </title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method ="post"> Username:<input type="text" name="username" /> Password:<input type="password" name="password" /> <input type="submit" name="submit" value="submit" /> </form> <?php $host = '---'; $user = '---'; $pass = '---'; $db = '---'; $connect = mysql_connect($host, $user, $pass) or die ('Could not connect'); $database = mysql_select_db($db) or die ('Could not connect'); $username = $_POST['username']; $password = $_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql= " SELECT * FROM Users WHERE username= '".$username."' AND password = '".$password."' "; $result = mysql_query($sql); if(mysql_num_rows($result) == 1){ $_SESSION['username'] = $username; $_SESSION['password'] = $password; header("location: login_succes.php"); } ?> </body> </html> code login_succes.php <?php session_start(); if(!isset($_SESSION['username'])){ header('location: login.php'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title> </title> <link rel="stylesheet" href="stylesheet.css" type="text/css" /> </head> <body> login succesfull </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.