Jump to content

Archived

This topic is now archived and is closed to further replies.

tomfmason

Unexpexted "\" on line 2

Recommended Posts

This is a very simple script. I have had all sorts of trouble with createing a login script but so far nothin has worked. Here is the simple script in question. This is the script that I get the error with.
[code]<?php
header('Location: http://www.owpt.biz/account.php?'.SID');
?>[/code]

I use the following login script
[code]<?php
session_start();

header("Cache-control: private");

$user = $_POST['username'];
$pass = $_POST['password'];

include("db.php");

$sql_user_check = "SELECT username FROM users WHERE username='$user'";
$result_name_check = mysql_query($sql_user_check) or die(mysql_error());
$usersfound = mysql_num_rows($result_name_check) or die(mysql_error());


if($usersfound < 1){
$error = "User ".$user." was not found in the database.";

$user = $_POST['username'];
$pass = md5($_POST['password']);
$sql = "select * from users where `username` = '$user'";
$result = mysql_query($sql);
while ($text = mysql_fetch_array($result)) {
$id = $text['id'];
$password = $text['encrytpass'];
$access = $text['access'];
}
if ($pass == $password) {
$error = "Wrong Username / Password <a href=\"../index.php\">Back</a>";

}else{
$_SESSION['username'] = $user_info['username'];
}
}

if(!$_SESSION['username']){
if($error){
echo $error;
include("index.php");
}else{
      include("header.php");
  }
    }else{
echo "<html><head><title>Welcomce Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index.php>Click here</a> to proceed.";
}
?>[/code]

I am wanting to pass the session id to account.php and at the same time hide the backend login process. I have tried several ways to acheive this.

I was also thinking, for security reasons I should maybe through in another session_start() in the header.php. Any suggestions would be great.

Share this post


Link to post
Share on other sites
<?php
header('Location: http://www.owpt.biz/account.php?'.SID');
?>

try

<?php
header('Location: http://www.owpt.biz/account.php?'.SID);
?>


you had a ' after SID

Regards
Liam

Share this post


Link to post
Share on other sites
Thanks but now I get the standard header error. I think I will try a javascript do I need to pass the SID when I do this javascript?

Share this post


Link to post
Share on other sites
You don't really need to pass the SID when your using sessions unless your specifically targetting users who disable cookies.

Also, there are better workarounds for header area's the resorting to javascript. read the sticky at the top of this forum.

Share this post


Link to post
Share on other sites

×

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.