Jump to content

Session to url


Gotharious
 Share

Recommended Posts

hello all,

 

What I want to do is, make the session ID clickable in a url here

 

Login Successful <a href="user.php">Conitnue</a>

 

so when a user logs in, his ID gets in the link of Continue so he can only see his information

 

so for example, if his id is 10, then the url would be ....user.php?id=10

 

 

Link to comment
Share on other sites

ok thanks, that's great

 

now what if I want to redirect based on the user type

 

I mean it looks up the database, and check the column type, and if this user is admin it redirects to admin.php, if staff then to staff.php and if client, then to client.php

 

I tried header but didn't work at all

Link to comment
Share on other sites

no, I'm not following now

 

ok here is the code, what do I need to add?

 


<?php
if (isset($_POST['email']))
{
$email = $_POST['email'];
$password = $_POST['password'];

//Query

$results = mysql_query("SELECT * FROM users WHERE email = '$email' AND password = '$password' ");
$row = mysql_fetch_assoc($results);
$count=mysql_num_rows($results);

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("email");
session_register("password"); 
header("location:index.php");
$_SESSION['id'] = $row['id'];
}
else {
echo "Wrong Username or Password, Please click back and try again";
}


mysql_close($con);

}
?>

Link to comment
Share on other sites

Ok, I've done it

 

here is the code I used

 

<?php

$results = mysql_query("SELECT * FROM users WHERE email = '$email' AND password = '$password' ");
$row = mysql_fetch_assoc($results);
$count=mysql_num_rows($results);

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("email");
session_register("password");

$_SESSION['id'] = $row['id'];
$type = $row['type']; 

switch ($type) 
    { 
    case ($type=='client'): 
    		    header("location:user.php"); 
        break; 
    case ($type=='Company'): 
    	    header("location:Users.php"); 
        break; 
    case ($type=='employee'): 
    	    header("location:employee.php"); 
        break; 
    } 

    	
    	}
else {
echo "Wrong Username or Password, Please click back and try again";
}



mysql_close($con);

}

?>

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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