Jump to content

Recommended Posts

I have a login that uses a session activation to make users login.  This is the code

<?php
$start = session_start();
$ob = ob_start();

// Recreation of variables for later encryption uses the $_POST  will be replaced with the decrypted source
$username = trim($_POST['username']);
$password =  trim($_POST['password']);
$cryptpassword = md5($password);
$url =  trim($_POST['url']);


//Connects to DB
require("includes/mysql_include.php");

$table = "users";
$sql="SELECT * FROM $table WHERE Username='$username' and Password='$cryptpassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
$storage=  mysql_fetch_array($result);


// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['loggedon'] = "yes";
$_SESSION['user'] = $username;
$_SESSION['firstname'] = $storage['Firstname'];
header("location: $url");
}
else 	
{
echo "Wrong Username or Password";
}

 

the page it returns to has this at the top to check if logged in:

session_start();
if (ISSET($_SESSION['loggedon'])) 
{$view = "login";}

I think my issue is that the page is sending headers and therefor session aren't starting any tips?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.