Session Based Login Script Re Login Problem
I have built this login script, it logs u in and shows the first page... i have built it to be require()'ed, when i have required it from a browser script i made it loads the front page, then when i ask for browser.php?edit=file.html
It then asks me to re login and takes me back to the front page! PHP Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Login Lgout And Login Without Closing Session Gives Redirection Error
I am stepping through a text book that sets up different websites. The one I am testing is user registration. I set up the scripts and this is what I observe: Login (verifying against a mysql db) - no problem. Logout - no problem. Close the browser and try again - no problem. Login > Logout > Login WITHOUT closing browser I get: An error occurred while loading http://login.php when it should redirect me to http://localhost/index.php. I read somewhere on the news group that the header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname ($_SERVER['PHP_SELF']) . "/index.php") (in my example code) is called once and so the error? The logout.php destroys the $_SESSION variables, session itself and any cookies so I thought it would be "like new" the second time around? It appears to be linked to sessions but don't know enough to know how to correct.
View Replies !
Browser Based Ftp Login
What I want to do is have an HTML page where users type in a username and password. After they click submit they are redirected to "ftp://username:password@domain.com" where they can download and upload files to their folder. Each username will have a folder in the directory that has the same name as the username. `So if "Mark" logs in, I want him to see the contents of the "Mark" folder where he can upload and download files. I don't want him to have access to anything else. As I know nothing, I did a lot of reading up and researching on how to do this (lots of great information on this site by the way) but the PHP code might still be way off. Here is the code I have so far: for the html login page: <html> <body> <form name="form" method="post" action="ftp.php"> Username: <input name="username" type="text" size="30"> Password: <input name="password" type="password" size="30"> <input type="Submit" size="8" value="Submit"></p> </form> </body> </html> the code for the ftp.php page is : <?php $ftp_server = 'domain.com'; //domain being the future website domain $ftp_username =$_POST['username']; $ftp_password =$_POST['password']; $location = 'ftp://$ftp_username:$ftp_password@$ftp_server'; header('Location: $location'); $ftp_connect_id = ftp_connect($ftp_server); $ftp_login = ftp_login($ftp_connect_id, $ftp_username, $ftp_password); if (! $ftp_connect_id || ! $ftp_login) { echo "Unable to connect to ".$ftp_server; exit; } else { echo "Connected to host "<p>"; } ftp_close($ftp_connect_id); ?> right now, when i check it, I log on the html page and go the the php page where all it says is "Connected to host." I don't see the "ftp://username:password@domain.com" that I want to see.
View Replies !
Display Images Based On Last Login
i have a image upload system in my site.in admin control panel i can see all the uploaded images with in particular dates for example 10-jan-2007 to 20-jan-2007 like this. now i want to put a button so that when i click that button it should display only those images that are uploaded after my last login and till to date.
View Replies !
Login Problem - Can't Login(login Is Done In Index.php)
This is origially PMsys, I have edited it, and here is what I have done with the original replace all $_COOKIE into $_SESSION changed all setcookie() into session_start() and defined those $_SESSION now the problem is I can't login(login is done in index.php), does anyone here got an idea why? I uploaded the whole pakage, but I think you only need to look at index.php and include/global.php.
View Replies !
Restrict User Access Based On The Login?
I'm creating a program in PHP/MySQL, for which I need to restrict user access based on the login. How can I restrict access based on login? I know you can do with creating different folders on windows server and assigning different a user rights, then put relevant pages into that folder. Is there any other way you can do that purely using PHP/MySQL that is quite robust enough? How can you decide which user gets access to which page?
View Replies !
How Do I Retrieve Images Dynamically Based On The Login Username?
I have created a site in Joomla with a login (no self registration, users are provided with username and password by the admin). The users are supposed to login to a specific page where they can see 4 images. I have the following code: <?php // define directory path $dir = "images/user1/"; // iterate through files // look for JPEGs if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (preg_match("/.jpg/", $file)) { // read EXIF headers $exif = exif_read_data($file, 0, true); echo "<tr>"; // get thumbnail // link to full image echo "<td valign=top><a href=$dir/$file><imgsrc=thumbnail.php?file=$file></a><td>"; echo "<td valign=top><font size=-1>"; // get file name echo "File: <b>" . $exif['FILE']['FileName'] . "</b><br/>"; // get timestamp echo "Timestamp: " . $exif['IFD0']['DateTime'] . "<br/>"; // get image dimensions echo "Dimensions: " . $exif['COMPUTED']['Height'] . " x " . $exif['COMPUTED']['Height'] . " <br/>"; // get camera make and model echo "Camera: " . $exif['IFD0']['Model']; echo "</font></td>"; echo "</tr>"; } } closedir($dh); } } ?> The question now is how to change the code to dimamically replace the folder name by the login username used. For example....if user2 logs in the images loaded will be only those in the folder images/user2, if user3 logs in it will be from the folder images/user3, etc... I am a little confused as to how to implement that in Joomla but as long as I have the code right I thinkI can just insert the code into the appropriate page using a mambot. If anybody here has any tips on how to accomplish that it would be extremely appreciated.
View Replies !
User Authentication -- Displaying Info Based On Login
I would like to display the database info based on the user's login. I am getting the following error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' $sql = "SELECT $_GET['user_id'] FROM table_auth_user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "".$row['user_id'].""; echo "<br /></div>"; }
View Replies !
Browser Based Ftp Login - HTML Page Where Users Type In A Username And Password
First let me say that I don't really know PHP at all. What I want to do is have an HTML page where users type in a username and password. After they click submit they are redirected to "ftp://username:password@domain.com" where they can download and upload files to their folder. Each username will have a folder in the directory that has the same name as the username. `So if "Mark" logs in, I want him to see the contents of the "Mark" folder where he can upload and download files. I don't want him to have access to anything else. As I know nothing, I did a lot of reading up and researching on how to do this (lots of great information on this site by the way) but the PHP code might still be way off. Here is the code I have so far: for the html login page: <html> <body> <form name="form" method="post" action="ftp.php"> Username: <input name="username" type="text" size="30"> Password: <input name="password" type="password" size="30"> <input type="Submit" size="8" value="Submit"></p> </form> </body> </html> the code for the ftp.php page is : <?php $ftp_server = 'domain.com' //domain being the future website domain $ftp_username =$_POST['username']; $ftp_password =$_POST['password']; $location = 'ftp://$ftp_username:$ftp_password@$ftp_server' header('Location: $location'); $ftp_connect_id = ftp_connect($ftp_server); $ftp_login = ftp_login($ftp_connect_id, $ftp_username, $ftp_password); if (! $ftp_connect_id || ! $ftp_login) { echo "Unable to connect to ".$ftp_server; exit; } else { echo "Connected to host "<p>"; } ftp_close($ftp_connect_id); ?> right now, when i check it, I log on the html page and go the the php page where all it says is "Connected to host." I don't see the "ftp://username:password@domain.com" that I want to see.
View Replies !
Login Script Doesn't Display If The Login Is Correct Or Incorrect.
Below is the script I am using for my login page. It doesn't display if the login is correct or incorrect. All it does is clear the username and password box when I hit submit. I want it to display an error message if the login is incorrect and if it is correct redirect them to their own web page. I am putting the MySQL connection script in the header of the login.html is this wrong? Can someone please give me some pointers on how to get this script working? <?php session_start(); $username = $_POST['username']; $userpass = md5($_POST['password']); $sql = "select * from usertable where username='$username' and password='$userpass'"; $result = mysql_query($sql); if (mysql_num_rows($result)!= 1) { $error = "Login failed"; } else { $row = mysql_fetch_array($result); $_SESSION['username'] = "$username"; $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; header("Location: h*tp://www.w-------.com/$row['USLP']"); } ?>
View Replies !
Create A Separate Page With One Login That Let's Me Login To All Of The Sripts At Once?
I'm building a website using various php scripts from I found on hotscripts. Because I'm not much of a programmer myself I'm using a separate script for the blog, another one for the links section and a different one for the gallery and so on. The downside to this is that I have to login on a separate page to update the gallery and another page to update the blog and so on. Is there a simple way to either remove the need for a login for all the scripts and just create a separate page with one login that let's me login to all of the sripts at once? Or if there's a script that can kinda save the passwords and logs in for me?
View Replies !
Secure Place To Store Login Info And How To Login With It
I had an idea to store my login code: ftp_login... in a separate file outside of the public_html dir and set full permission (777) to it. 1. Is that safe? 2. How do I call this function from inside another file? function Login() { $connection= ftp_connect('ftp.me.com'); return ftp_login($connection, "me", "pass"); } I was hoping to return connection but I don't know how to send pointers in php.
View Replies !
Authenticate The User With The Login.html, Login.php.
I am setting up a registration/login for my website with PHP and MYSQL. I have a register.html, register.php & a login.html, login.php. I can successfully register a user (using register.html, register.php) into my database. Now, I am trying to authenticate the user with the login.html, login.php. When I try to do so, however, I always recieve my error message "failed." It will not authenticate (despite several attempts of logging in with the same username and password of that which is in my database.) Code:
View Replies !
Hiding Login & Password Fields After Login
I am hoping to do the following, the homepage shows a username and password field. Once the user enters a scucessfull login, these fields are removed. In order to achieve this, must the page be based on one big IF ELSE statement? so... If user logged in hide username & password fields Else show page with username and password fields? OR is this acheived by redirecting the user to a page that is not the homepage after a successfull login? so... the user would login sucessfully and be redirected to a homepage identical to the one with the fields but will have the username & password fields removed?
View Replies !
Main Page Login = Forum Login
This is going to be a website for a club im in at University. Now, I only want members of that club to be able to register. The problem is that they pay a member fee. I want to know a way that when they pay me the fee (in person) I can give them a unique confirmation number from which they can register properly (sorta like a CD-Key). Code:
View Replies !
Session/login
ive just written this code for a simple log in form but im having some trouble with the session variable <? session_start(); $username=$_POST['username']; $password=$_POST['password']; echo $username; echo $password; include('config.php'); $sql="SELECT * FROM regcustomer WHERE username='$username' AND password='$password'"; $query=mysql_query($sql) or die("Queryfailed:".mysql_error()); if (mysql_num_rows($query) != 0) { $row = mysql_fetch_assoc($query); $_SESSION['username'] = $row['username']; $username=$_SESSION['username']; echo "$username"; } //header("Location:default.php"); ?> when i echo the session variable it doesnt print anything, however if in the sql statement i put a username and password it works....i dont know where im going wrong!
View Replies !
PHP Login Session
Ok, my registration/login script was working fine until I tested the registration and registered a new user. Once I logged in with the new account, I logged out and then logged into the first account. Everything was fine until I clicked on a link to a page that also uses the session. The only problem is that for the username, it displays the username for the second account. I thought the logout was successful because it no longer displayed the login form at the top of the page. What do you guys think is causing the problem?
View Replies !
Login Session
Recently added a login to my site from some freeware code. I put it on the user submit sections so users must register and login before submiting comments ratings etc. However I pass form data which is submited to the database in the query string and this is dropped after the user logs in. Heres the code:
View Replies !
Session Login
I saw some other topics on here and found some stuff on google but it didn't help. I saw how to make a register page but that's not what I need. I need a login script that sets a cookie. I also need to know how to check for the user on pages that I don't want non users to see. I already have the table set up with 'id', 'username', and 'password'.
View Replies !
Session And Login
I have a login page and user homepages if looged in. Now I want to check ifthe user has privilage to view that perticualr page. <br> For Example. <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th scope="col">Dept</th> <th scope="col">hompage</th> </tr> <tr> <td>IT</td> <td>IT.php </td> </tr> <tr> <td>HR</td> <td>HR.php</td> </tr> <tr> <td>Accounts</td> <td>Acc.php</td> </tr> </table>
View Replies !
Session Login App
I"m writing simple and small login app using php session variable. I have 3 php scripts. The first is just a simple php form, login.php, that passes the variables to auth.php. Auth.php just validates that the username and password is correct. If they match, i will set the php session, $_SESSION['logon'] = "ok", then redirect the user to anothor page, ADMIN.PHP ADMIN.PHP: Code:
View Replies !
Login Script With Session
i have read many articles and i see that people use sessions to register users usernames and passwords, what i have done on my site is that whenever the user logs in i register a session with his (user)id... is it okay or is it very easy to hack?
View Replies !
Ending Login Session
whenever a user logins into the control panel of my script correctly i do this: session_start(); $_SESSION['login'] = 'superuser'; Then on the site to check if the user is login i use: <?php session_start(); if(!(array_key_exists('logeado',$_SESSION) && $_SESSION['logeado'] == 'superuser')) { die; } //end if ?> I need a code to put on a php page to end the session and put a link to it inside the panel so if the user clicks it then press the back button he cannot go back and see the control panel.
View Replies !
Session Information During Login
I have a script for login. It works fine. The people can login ect.. I save the session information during login. It even prints out the correct info. But when they go to another page like main.php it loses all the info and goes you are not loged in.
View Replies !
Login Won't Recognize Session
I've tried a gazillion different combos to get this to work. Basically I have a page that, to be viewed, they must register first. The registration works fine. Once they register they have to log in with username/password. Password is 'hashed' with MD5. On login it's showing the error section indicating they haven't logged in. But, if I remove the if(isset($_SESSION['searchlog']) part it works fine. In other words, when i'm trying to protect it from being viewed without first logging in and setting a session they can't get in. Ideas? Code:
View Replies !
Login / Session Fails On IE6
I am writing a login script to administer a backend CMS, and I've noticed that the login script fails completely on ie6. The login page posts to itself, and checks the values against a MySQL database. If it gets a match, it sets some session variables and redirects to the index page. The index checks to see if the logged variable is set in the session, otherwise it redirects back to the login page. Both pages are prefaced with: session_start(); header("Cache-Control: private"); The latter of which I heard would fix the problem with sessions in ie6. The login/session works fine in firefox/camino/safari/ie7, but not ie6. In ie6 you hit submit and it just goes back to the same page with the values erased from the form (which shouldn't happen either, since their value is set to $_POST['...'] if the form posted right). The full login.php is posted below: ....
View Replies !
Login Session Problem
just now is to make a simple login authentication using session.... Ok I able to do a login then set the session only my problem is when i Try to access in restricted page it's seem not recognise me..then it'll redirect to the login.php. eventhough after successful login...really weird..?... ok below I paste the code I currently using.
View Replies !
When To Create A Session After Login
I have created a signup page and login page that work. Right now, if your user name and password match, it just says you have logged in, if they don't, it puts you back at login screen. I have not messed with sessions before. Do I create the session after the query and verifys the login? And then have it load my menu page, where i would call session?
View Replies !
How Can I Transmit Session Id In Login
I am developing a website using php 5.2.1 with mysql. I want to transmit session id in login and useing certain form to only validated users. Now My attached form can be used anybody by simple type full URL in address bar. I want to use that form only validated users. I used with some variable but it cann't worked in some other pages. How can I transmit session id ?
View Replies !
Storing Login Name In Session
i m storing login name in session and i wanna make logout so i m using unset function but its not working and the session still has the variable. here is my code if(isset($_SESSION['Login_Name'])) unset($_SESSION['Login_Name']); echo '<script language="javascript"> window.location="login.php"; </script>'
View Replies !
Login/session Issue
I have written a simple script for logging into a secure section of my website. Form, process page that continues on if correct (sets session) or displays a message on failure. Everything worked fine for a few days but now it doesnt. Logins incorrectly will display the error message and kick you to the login page but correct logins will display no message and kick you back to the login page. Now it seems like if I make any change to the process page it work for a few days and then break again.
View Replies !
Session Handling - Login
I have created three .PHP files as main.php which asks for username, password and forwards it to checklogin.php which has connection details for the MySQL database. After entering login details on main.php, it successfully checks if the username and password entered are correct or not, and shows the appropriate message, which means that main.php and checklogin.php are working correctly. Code:
View Replies !
Session Problem With Login Script
I hope someone can help me figure out what's going on here. I've re-read the section on sessions at php.net and Googled this high and low but I haven't found anything that quite explains my problem. The basic problem: session data (e.g. $_SESSION['access_level']) gets dropped after visitor logs in and reloads the page via a form once or twice (it seems to vary), requiring the visitor to re-login, whereupon the problem repeats itself. An outline of my login script: 1. a function protect_page at the beginning of the protected page's script checks to see if the visitor is logged in by checking two session values ($_SESSION['access_level'] and $_SESSION['login_time']). 2. if logged in with sufficient access and session not too old, show page. if not, require_once an include file that displays a login form (everything's buffered, so it's not a header problem) 3. post login form, check credentials; if ok, display protected page I have a log that tracks the behavior but it's a bit too long to include here. One peculiarity I've noted is that after logging in, when I post the form on the protected page, it appears to successfully load the page once with the session data. But then it reloads the page a second time (according to the log) and the session data is lost -- thus logging me out! There's nothing in the script that should trigger the page to be reloaded. I use session_regenerate_id to avoid session fixation. Could this be a factor? Another complication: this problem occurs on two development servers (one running XAMPP on Linux, the other WAMP). But on a third running WAMP, it doesn't happen and everything runs as designed. Finally, I took note of the following posts describing similar problems with session data being lost: Initialize crucial SESSION data (http://us2.php.net/manual/en/functi...close.php#63970) Use session_write_close after assigning crucial SESSION data (http://us2.php.net/manual/en/ref.session.php#62486) Turn off ZoneAlarm (http://forum.sydphp.org/index.php?a=topic&t=255#p7) However, the suggestions offered (e.g. using session_write_close() liberally, turning off ZA ) did not solve my problem. And my php.ini file appears to be in order. I hope this is clear and detailed enough. Does anyone recognize it? Any help is appreciated.
View Replies !
Login Logout And Session Expire...
Any Suggestions for an Authentication System ... Do you have any Links to suggest ? My current Authentication works ok but it has a major BUG !!! BUG: If I use the same Authentication mechanism in Two Different Websites and I login in one of the two... Then I can change the URL to the other website and it will log me in as the user of the other Website. Anyway... I knew when I was writing that is not going to be perfect... but maybe you can show me the door to getting it fixed. What I actually do is this simple thing: if (!isset($_SESSION['user_id'])) echo '<a href="login.php">Login</a>' YES I know it doesn't even go close to an Authentication Mechanism... But it does its job for a begginner... Every page I call has a header.php and a footer.php so I just have to make the Authentication in the Header...
View Replies !
Login Session Data Problems
Im having trouble storing sessiondate on user login for my shopping cart, it works fine the first time but if I logout and log back in again it says this: Notice: Undefined index: username in c:inetpubwwwrootmymarketlogin.php on line 23 and repeats it a few times for the other variables, here's the code:
View Replies !
Simple Session Login Problem
I created a php page that will create a session for a user. My problem is that once they are logged in, I dont know how to send them to the secure page. I dont know where to place the following lines of code: (also not sure where on the server the pages are placed) header("Location: http://www.mysite.com/index.html"); exit; Original code------------------------------------------------- <? session_start(); ?> <html> <head> <title> </title> </head> <body> <? $_Username = "user"; $_Password = "password"; // If the form was submitted if ($_POST['Submitted'] == "True") { // If the username and password match up, then continue... if ($_POST['Username'] == $_Username && $_POST['Password'] == $_Password) { // Username and password matched, set them as logged in and set the // Username to a session variable. $_SESSION['Logged_In'] = "True"; $_SESSION['Username'] = $_Username; } } if ($_SESSION['Logged_In'] != "True") { echo "<form method="post" action="" . $_SERVER['PHP_SELF'] . ""> Username: <input type="textbox" name="Username"><br /> Password: <input type="textbox" name="Password"><br /> <input type="hidden" name="Submitted" value="True"> <input type="Submit" name="Submit"> </form>"; } else { echo "You are logged in as: <b>" . $_SESSION['Username'] . "</b> <br /><a href="" . $_SERVER['PHP_SELF'] . "?mode=logout">Logout</a>"; } if ($_GET['mode'] == "logout") { session_start(); $_SESSION = array(); session_destroy(); echo "<META HTTP-EQUIV="refresh" content="1; URL=" . $_SERVER['PHP_SELF'] . "">"; } ?> <p> </p> </body> </html>
View Replies !
Secure Session / Login Data
I have a login form that uses 5 sessions. Each page then checks to see if each session is either active or a specific value. Is this a secure method, since I have no ability to use .htaccess methods.
View Replies !
Create A Session For A Login System.
I have php 5 and I am trying to create a session for a login system. My code is below: <?php session_start(); register a session-variable session_register("color"); $color = "blue"; However upon running this script the following error occurs: "Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0" I can view the session being created in a tmp folder but cannot store variables within sessions or view the sessionID. I toggled the register_globals from off to on in the php.ini file and saved that however the changes were not reflected when I ran the script: </php phpinfo(); ?> Is there another way to toggle register_globals. Will this solve my sessions problem?
View Replies !
Start The Session On Login Script
im trying to get my sessions working but they dont seem to work. where do i need to start the session? would it be on my login script or the page that the user gets directed to from there? and how do i validate that the user is logged in on the remaining pages?
View Replies !
Session Variables - DMX Login Sql Query
I have extended the DMX login sql query to include a 4th table field in the hope of being able to return an additional $variable from the LoginRS protocol. This didnt seem to work in establishing or reading the returned data succesfully into the new session variable.
View Replies !
Looking For Simple MySql Login/Session
I've never had any password protection so far so, I'm rather new to the coding...(I know the process though--) Anyway, I've been looking for a good tutorial on google and on the search option on these forums for a way to easily have a secure, yet simple register/login/session pages--Explaining tutorial... Also, I will edit the register form so that it carries more information, I'd prefer if the tutorial would just look for username then password in the database and ignore any other columns..
View Replies !
|