sharal Posted October 1, 2009 Share Posted October 1, 2009 Heya, i'm writing an application where the users profile information is stored in a php file - i want to include that specific file now. I'm doing this by getting the users profile file via his / her session. It can be discussed how safe that is, but it's nothing thats going live anyway I've checked if there's any errors in the "username.php" file ofcourse, which there isn't - i don't get any parse errors either, it just doesn't work. This current line doesn't work as it's not quoted ofcourse, but it's just an example of what i want to do and have been trying <?php include ($_SESSION['username'] .".php");?> Hope you can help me Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/ Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 sorry but what you trying to do completely please... Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/#findComment-928255 Share on other sites More sharing options...
sharal Posted October 1, 2009 Author Share Posted October 1, 2009 what i'm trying to do is, to include a file that has the name of the user. For instance, lets say that your username is Redarrow. Your profile file would then be named Redarrow.php, if your name was Sharal. It would be named Sharal.php. Now i want to include the correct file depending on which user logged in. So if it's you who logged in it would include your profile file "Redarrow.php", if it was me. Then it would include "Sharal.php", which i want to do by getting the session username, where your username is stored in eg: $_SESSION['username'] = Redarrow. $cuser = $_SESSION['username']; include($cuser . ".php"); just an example Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/#findComment-928256 Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 so a user first log in then his/her session is set correct? Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/#findComment-928257 Share on other sites More sharing options...
sharal Posted October 1, 2009 Author Share Posted October 1, 2009 yes, this is how it works in the reg part <?php $_SESSION['username'] = "$user"; // variable from html form. $_SESSION['pw'] = "$shapw"; $_SESSION['ses'] = "$ses"; $_SESSION['loggedin'] = 1; ?> Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/#findComment-928258 Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 example only <?php session_start(); $_SESSION['username']="redarrow"; if(isset($_SESSION['username'])){ include_once($_SESSION['username']).'.php'; }else{ header("location: index.php"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/176148-solved-include-problem/#findComment-928260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.