Jump to content

Recommended Posts

I have a system where a user can log into the members area. Is there a way for the users to edit their profile WITHOUT using session_id? My database table looks like this:

 

ID, Name, Surname, Address, Email, Username, Password.

 

In other words, when the person logs in, I want the ID to be dragged with it and available on the members index page on the Edit Profile Link, ie. edit_profile.php?id=35.

 

Can someone please help?

 

Thanks,

Karen

Link to comment
https://forums.phpfreaks.com/topic/67028-getting-user-id/
Share on other sites

This is the code for the login page. The actual HTML code for the form begins just underneath it:

 

<?php

// Connecting, selecting database 
include('../../includes/conn.inc.php'); 
include("../../includes/user_member.inc.php");
include("../../includes/validate.inc.php");
include("../../includes/error_report.inc.php");

$user = new user($db, members);

   	if(isset($_POST['remember'])){
      setcookie("cookname", $_POST['username'], time()+60*60*24*100, "/");
      setcookie("cookpass", $_POST['password'], time()+60*60*24*100, "/");
   } 
  
  
   
   if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
      $_SESSION['username'] = $_COOKIE['cookname'];
      $_SESSION['password'] = $_COOKIE['cookpass'];
      $user->login($_POST['username'], $_POST['password']);
   }

$validate = new validate("error");


if (isset($_POST['username']) && isset($_POST['password']))	{	
	$error["username"] = $validate->field($_POST['username']);
	$error["password"] = $validate->field($_POST['password']);	
	$error["email"] = $validate->field($_POST['email']);	
	$user->login($_POST['username'], $_POST['password']);
}
else {

 

And this is the members index page:

 

<?php
// includes
include("../includes/conn.inc.php");
include("../includes/user.inc.php");
include("../includes/error_report.inc.php");

// authorizing
$user = new user($db, "members");
$user->authorize("../public/eng/login.php", array("Member"));
?>
<?php

if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
             $_SESSION['username'] = $_COOKIE['cookname'];
            $_SESSION['password'] = $_COOKIE['cookpass'];

   }

$sql2 = "SELECT * FROM members WHERE id = '". $_SESSION["id"] ."'"; 
            $sql2 = mysql_query($sql2); 
$result2 = mysql_fetch_assoc($sql2); 

?>

 

The edit profile link is as follows:

 

<a href="profile_update.php?id=<?= $result2['id']; ?>

 

Don't worry about the authorization coding. That's just for the difference access levels that I have.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/67028-getting-user-id/#findComment-336172
Share on other sites

why not store the user ID the same as your storing the username ?

 

i assume you know the security problems with the script above, maybe include a checksum, ie

setcookie("cookid", $ID, time()+60*60*24*100, "/");
setcookie("cookhash", md5($ID.$username."StaticSiteSalt"), time()+60*60*24*100, "/");

 

then to check the id

if($_COOKIE['cookhash'] == ($_COOKIE['cookid'].$_COOKIE['cookuser']."StaticSiteSalt"))
{
//valid
}

Link to comment
https://forums.phpfreaks.com/topic/67028-getting-user-id/#findComment-336344
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.