Jump to content

sessions


MattCv1

Recommended Posts

im new to php I have this login script that works fine just trying ot add a session variable to get the data from the field usertype (this will be set as admin or user)

ive tried the code below but getting parser errors the parts i have added that are not functioning are

$usertype = $_POST['usertype'];

$_SESSION['valid_type'] = get($usertype, "admin");

Just want to know how to get this session to work correctly like the others do any help appreciated

code below.
[code]
<?
include "functions/include_fns.php";
if (isset($_POST['username']) && isset($_POST['password'])) {

$username = $_POST['username'];
$password = $_POST['password'];
$usertype = $_POST['usertype'];

if (login($username, $password, "admin")) {

$sql

$_SESSION['valid_user'] = $username;
$_SESSION['valid_name'] = getname($username, "admin");
$_SESSION['valid_type'] = get($usertype, "admin");

if (isset($_POST['url']) && !empty($_POST['url'])) {
$go_url = "".$url;
header("Location: $go_url");
} else {
header("Location: home.php");
}
exit;
} else {
//status = 0: Incorrect Username or password
//status = 1: Session has timed out or your are not logged in
header("Location: index.php?status=0");
exit;
}
} else {
header("Location: index.php?status=0");
exit;
}
?>[/code]
Link to comment
Share on other sites

I'm not sure what you are asking here, but your parse error is $sql

<?
include "functions/include_fns.php";
if (isset($_POST['username']) && isset($_POST['password'])) {

$username = $_POST['username'];
$password = $_POST['password'];
$usertype = $_POST['usertype'];

if (login($username, $password, "admin")) {

[color=red]$sql[/color]

$_SESSION['valid_user'] = $username;
$_SESSION['valid_name'] = getname($username, "admin");
$_SESSION['valid_type'] = get($usertype, "admin");

if (isset($_POST['url']) && !empty($_POST['url'])) {
$go_url = "".$url;
header("Location: $go_url");
} else {
header("Location: home.php");
}
exit;
} else {
//status = 0: Incorrect Username or password
//status = 1: Session has timed out or your are not logged in
header("Location: index.php?status=0");
exit;
}
} else {
header("Location: index.php?status=0");
exit;
}
?>


Also you have some functions like get() ,getuser() and login() that affects your code here.
If this is a 3'rd party script i suggest you try the forum-section --> [url=http://www.phpfreaks.com/forums/index.php/board,34.0.html]http://www.phpfreaks.com/forums/index.php/board,34.0.html[/url]
Link to comment
Share on other sites

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.