[PHP] Session End
Hi I am have created an authentication system, wherein the user is authenticated on the basis of a MySQL database. Here is the code $auth = false; // Assume user is not authenticated if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) { // Connect to MySQL mysql_pconnect( 'localhost', 'mysql', 'sunny' ) or die ( 'Unable to connect to server.' ); // Select database on MySQL server mysql_select_db( 'testbed' ) or die ( 'Unable to select database.' ); // Formulate the query $sql = "SELECT * FROM guest WHERE login= '$PHP_AUTH_USER' AND password = '$PHP_AUTH_PW'"; // Execute the query and put results in $result $result = mysql_query( $sql ) or die ( 'Unable to execute query.' ); // Get number of rows in $result. $num = mysql_numrows( $result ); if ( $num != 0 ) { // A matching row was found - the user is authenticated. $auth = true; session_start(); } } if ( ! $auth ) { header( 'WWW-Authenticate: Basic realm="Pushpinder Singh\'s World"' ); header( 'HTTP/1.0 401 Unauthorized' ); echo 'Authorization Required.'; exit; } else { echo 'You are authorized!'; } ?> However this keeps the user logged on. I want to be able to close the session once the user has finished his work. How do I do that?? Many Thanks --pS Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc. Off : 704 987 6500 Cell : 704 236 2939 Fax : 704 987 5002 _
[PHP] PHP and MySQL
Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; WHEN I TRY TO HARD CODE THE VALUES INTO THE MYSQL QUERY, IT WERKS FINE // $sql = 'INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES (\'gh\', \'ghdfghhgj\', \'hgddj\', \'ggfgfg\', \'hfgdj\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());'; Can somebody please tell me where I am going wrong..?? Many thanks Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc.
Re: [PHP] PHP and MySQL
Thanks Jason...that werked fine for me.. --pS On Wednesday, December 11, 2002, at 03:50 PM, Jason Wong wrote: On Thursday 12 December 2002 04:30, Pushpinder Singh Garcha wrote: Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; Not sure why you're escaping the single quote. It's unnecessary -- and I suspect you mis-escaped $select as well. Any you can use this format, which IMHO, is a lot easier on the eyes: $sql = "INSERT INTO `guest` SET `title` = '$title', `first_name` = '$first_name', ..., ..., `last_visit` = NOW()"; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I had a lease on an OEDIPUS COMPLEX back in '81 ... */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help Needed
hello all I am using php and mysql in my web application. I am making use of forms to accept data from the user and add it to the mysql database. I also have a login system in place. I need to create a way for the user to edit the information that he/she entered. Can you suggest a way I can do that. I want to be able to display a form to the user where his information is present ... and then he/she can go ahead and make updates. thanks --pS Pushpinder Singh Garcha _
[PHP] Session Problem
Hello I am trying to make use of sessions to auhenticate users on the secure parts of the website. Things seems to work fine...but I keep getting this warning. Can some one pl explain what this means ... Warning: Cannot send session cache limiter - headers already sent (output started at /Users/pgarcha/Sites/edit.php:7) in /Users/pgarcha/Sites/edit.php on line 8 Thanks in advance --pS Pushpinder Singh Garcha
[PHP] Session Length
Hello Everyone: I am using Sessions to secure parts of my website. I need to know if there is a way to set a lifetime for these sessions , so that they are automatically destroyed when say the user is inactive for 30 minutes. Any help will be greatly appreciated. Thanks in advance Pushpinder Singh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic List Using Php
Hello All I am wanting a create a dynamic List using php. When a user enters a value on a form, I need the value that he entered on the form to added to a dynamic list box, which is displayed on the next page. So the List Box continues to grow whenever a user adds a value on the form (note: The values entered every time have to be stored) Thanks in advance. Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc. _
[PHP] Ecard Senders
Hello there, I am looking around for some E card senders based on PHP and MySQL . Duz anyone have any ideas which I should use.? Please let me know... I really appreciate it, best Pushpinder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help needed with session variables
hello, I am making use of sessions in my PHp/MySQL Database application. When the user is successfully authenticated against the database, a session is created in following manner: session_register("valid_user","firstname","lastname"); $valid_user = $login; $firstname = $first_name; $lastname = $last_name; While I am able to use the $valid_user variable all thru the sesion , when I try to use the $valid_user it works fine (i.e. I am able to access the value) throughout the session, however when I try to use the other two registered session variables i.e firstname and lastname, I am not able to extract the value. Can you suggest what might be going wrong. Note I am locally testing the setup on my Mac. Many Thanks Pushpinder Singh Garcha _ Web Architect
[PHP] Help Needed
Hello All: I am using PHP and MySQL in my application. I need to be able to allow ONLY authorized users access to some pages in the site. For this I am creating a session variable ''$valid_user", after the user has successfully authenticated himself with the Database. The pages that need to be protected are all HTML files. So far everything, works fine. I am wondering how to finally deploy the logic on all the pages that need to be protected. Here is my point of view. 1). Change all the names of the protected documents to .php 2). Use the following script: if (session_is_registered($valid_user)) { // show the original page PLEASE TELL me a way to display the same page } elseif (!session_is_registered($valid_user)) { // display an error message to the user asking him to login before he can see this page } many thanks --Pushpinder Singh Pushpinder Singh Garcha _ Web Architect
[PHP] Help Needed
Hello All: My question is related to authentication. I have made a login system using PHP Sessions and MySQL. Once the user gets authenticated on the website I want to be able to allow him to see some html pages on the website. Only users who have logged in are able to see such a files. I have asked this question before , but still I have some doubts. My code will check for: if (session_is_registered($valid_user)) { /// display the reqd page } else { DISPLAY ERROR MESSAGE and ASK USER TO LOGIN } How should I display the page ... the page has a lot of html code and trying to write echo " blah blah blah . "; will not be a an option. Please suggest a way out . Many Thanks Pushpinder Pushpinder Singh Garcha _ Web Architect
Re: [PHP] Re: Help Needed
Hello All: Thanks again... I tried to use this and it is working fine for me. Please comment: Many Thanks -Pushpinder On Tuesday, February 4, 2003, at 12:32 PM, Goetz Lohmann wrote: Pushpinder Singh Garcha schrieb: Hello All: My question is related to authentication. I have made a login system using PHP Sessions and MySQL. Once the user gets authenticated on the website I want to be able to allow him to see some html pages on the website. Only users who have logged in are able to see such a files. I have asked this question before , but still I have some doubts. My code will check for: if (session_is_registered($valid_user)) { /// display the reqd page } else { DISPLAY ERROR MESSAGE and ASK USER TO LOGIN } How should I display the page ... the page has a lot of html code and trying to write echo " blah blah blah . "; will not be a an option. Please suggest a way out . you could include every page into a php script using this mean, that this page is like being copyed in the php file also instead of you always can do bla bla bla -- @ Goetz Lohmann, Germany | Web-Developer & Sys-Admin \/ -- () He's the fellow that people wonder what he does and || why the company needs him, until he goes on vacation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Pushpinder Singh Garcha _ Web Architect
[PHP] Protect Access to a Directory
Hi, I am using PHP and MySQL in my application. I have created a Login System for using "Sessions". The problem that I am facing is that I need to protect a large number of pages in my website. So I have tried to use this method and it works fine for me : if (session_is_registered("valid_user")) include ('guest.html'); else include 'not_logged_in.php'; ?> I get stumped here in order to be able to insert this code I have to write for each of the 400 html files, 400 php files with the same name. Most of the files are arranged in the form of directories. Is there a better way to be able to do this (Using PHP and MySQL). Thanks in advance ! Best Wishes Pushpinder Singh Garcha _ Web Architect
[PHP] PhpMyADmin Help
Hello , I am using PhpMyAdmin to control my MySQL Database. Untill now I had been using the Local Apache webserver to test my scripts, so I had installed PhpMyAdmin in the 'Sites' Folder of my Mac. Now I need to beta test the Application on the Live Server. Do I need to upload PhpMyAdmin on to the remote site? Or can I let it remain sitting on the local server. Also, I was wondering , what value should I assign to the $cfg['PmaAbsoluteUri'] variable in the config.inc.php file. Many Thanks, Pushpinder Pushpinder Singh Garcha _ Web Architect
[PHP] Php security
Hi all i wanted to check with if it is possible to see the contents of a .php file. I have heard of the Zend Encoder, but I was wondering how could a person see my php script ? Any information in this direction would be useful? TIA --Pushpinder Singh Garcha _ Web Architect
[PHP] PhpBB2 Error
Hello All, I have been runing PHP BB2 successfully on my site for a couple of months . Recently I got this error. phpBB : Critical Error Could not connect to the database Can someone tell what this means..?? Many Thanks --Pushpinder Singh Garcha _ Web Architect Pushpinder Singh Garcha _ Web Architect
[PHP] Error Opening file
Hello All; I am trying to open a File called cmi_list.txt ( stored at the same level as the php file) and then load these into an array. Now I check the $passport_codes with the value the User has entered and set the $flag accordingly . $PASSPORT_CODES =file("cmi_list.txt"); $count = count($PASSPORT_CODES); for($i=0 ; $i < $count ; $i++) { if ($PASSPORT_COUNT[$i] != $p_code ) $flag = "true"; else $flag = "false"; } if ($flag == "false") { echo "Passport Code did match record on file\n\n"; exit; } . . ?> This does not seem to work correctly.
[PHP] Date/Time Logic
Hello Everyone, My php/mysql application needs to keep track of the first time that a User logs on to the site. Afterwards the User should be allowed either 3 days / 3 months/1 year of access to the site. Once the stipulated time period is over the system should invalidate the login of the user. The Admin/ User should get email notification about this. The notification part is easy the hard part to figure out is how to be able to keep and tab on the Time Period stipulated for a user. Thanks in advance Pushpinder Singh Garcha _ Web Architect
[PHP] Cron Job help Needed
Hello All, I need to ask you about some resources for "cron" jobs. Please suggest some online help Thanks Pushpinder Singh Garcha _ Web Architect
[PHP] File Trouble
Hello All I am trying to load the contents of a file stored on the server in to an array. The file has 125 or so lines. However when I load the file into the array and try to print the array elements..all I see is one continuos line. $PASSPORT_CODES=file("../GUEST/list.txt"); if(!$PASSPORT_CODES) { echo "File could not be read by the system !! "; exit; } else echo "File was opened !!"; $x = count($PASSPORT_CODES); echo "Count is : $x"; for($i=0; $i"; } Can you please help me out with this I need to get a 125 element array...so that my code can check the individual elements of the Array. Thanks in advance Pushpinder Singh Garcha _ Web Architect
[PHP] Still having File trouble
Hello all, I am trying to read the contents of a file called 'file.txt' into an array and then compare it with the user inputs. when I read the file it gets stored as a single line. I am trying to get a way around that but alas. I would really appreciate any help. Thanks --Pushpinder HERE IS THE TEST CODE /* abc111 asd123 aqw234 www234 edr234 vfr456 */ $p_code = "abc111"; echo "The passport code that was entered in the system was $p_code"; $PASSPORT_CODES = file("file.txt"); if(!$PASSPORT_CODES) { echo "File could not be read by array !! "; exit; } else echo "Array was opened !!"; $x = count($PASSPORT_CODES); echo "Array Count is: $x"; for($j=0; $j<$x; $j++){ echo "$PASSPORT_CODES[$j]"; } $A = array("\r\n", "\n\r", "\r", "\n"); $P = str_replace("$A", "\n" , "$PASSPORT_CODES"); //then simple explode() the data to receive an array of lines: $P = explode($P,"\n"); for($i=0; $i if (rtrim($P[$i])==$p_code) { $flag = "true"; echo "Congratulations, $f_name your passport code has been accepted by our system !"; break; } else { $flag = "false"; } } if ($flag == "false") { echo " Sorry, your passport Code was not accepted by our system !"; exit; } ?>