sapheroth Posted March 1, 2007 Share Posted March 1, 2007 hi i m new to php and want some help. i want to create a php page where a person authenticates himself with username and password.and then moves to the next page. this next page should be a text editor.where that person puts his remarks with his name and time. and then save it. the next time when that person login to this page he can see the last comments entered by him. i have downloaded some scripts written in php for authentication but dont know how to connect them to mysql(rurring on linux). can any1 plz help me solving this problem. regards Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 1, 2007 Share Posted March 1, 2007 In most cases those downloaded scripts would have instructions on setting it up to work with your Mysql database. Post the code of the login form/file and let's see what we can do. Quote Link to comment Share on other sites More sharing options...
sapheroth Posted March 1, 2007 Author Share Posted March 1, 2007 thanx for your responce.. i have uploaded the file the link is http://www.filefactory.com/file/af35c7/ http://www.filefactory.com/file/650f6c/ these two scripts are for the purpose of authentication(as far as i know).. plz take a look at them and then plz help thanx Quote Link to comment Share on other sites More sharing options...
sapheroth Posted March 2, 2007 Author Share Posted March 2, 2007 any1 ??? Quote Link to comment Share on other sites More sharing options...
chronister Posted March 2, 2007 Share Posted March 2, 2007 POST YOUR CODE HERE... you will find most folks don't want to risk downloading a .zip file for fear of virus infection. Just copy the code and paste it here... be sure to enclose it in code tags (the # sign above). Sounds to me like you need to grab the user id once he logs in and then simply run a query to get the last post that user has posted. Quote Link to comment Share on other sites More sharing options...
sapheroth Posted March 2, 2007 Author Share Posted March 2, 2007 ok....... <? $title = "Customer Login"; ?> <HTML> <HEAD> <TITLE><? echo "$title" ?></TITLE> </HEAD> <BODY> <BR> <FORM METHOD ="POST" ACTION="accesslist.php"> <table width="80%" cellpadding="0" cellspacing="0" border="0"> <tr> <td> <FONT SIZE="-2">Please Login:</FONT><BR> <input type="text" name="name" size="20" maxlength="20"> <input type="password" name="passin" size="10" maxlength="10"> <input type="submit" name="submit" value="go"> </td> </tr> </form> </table> </body> </HTML> and <? switch ($name) { case "chris": $pass = "test"; $url = "<a href='http://www.icehousedesigns.com'>Click here</A>"; $meta = "http://www.icehousedesigns.com"; break; case "nick": $pass = "test2"; $url = "<a href='http://www.endzero.com>Click here</A>"; $meta = "http://www.endzero.com"; break; case "yahoo": $pass = "test3"; $url = "<a href='http://www.yahoo.com'>Click here</A>"; $meta = "http://www.yahoo.com"; break; case "google": $pass = "test4"; $url = "<a href='http://www.google.com'>Click here</A>"; $meta = "http://www.google.com"; break; case "teoma": $pass = "test5"; $url = "<a href='http://www.teoma.com'>Click here</A>"; $meta = "http://www.teoma.com"; break; // if none of them match... default: $url = "Sorry, access denied"; break; } ?> now plz guide me Quote Link to comment Share on other sites More sharing options...
chronister Posted March 2, 2007 Share Posted March 2, 2007 This looks like it simply stores the username and password in a php script and this does not use a database. You will need to probably write what you want from scratch. I have to ask, how much do you know about php / mysql scripting? What you want is not a terribly hard task, but if you don't know php / mysql then it will be almost impossible. You have your login form. The switch statement, simply says if its this user then do this elseif it's this user do this etc..... To truly have a login form you will need a $_SESSION[''] variable to store the username or user id or the like. A session (or cookies) is the only way to store the state of a particular user. Quote Link to comment Share on other sites More sharing options...
sapheroth Posted March 5, 2007 Author Share Posted March 5, 2007 ok let me explain i m given task to create a webpage in php/mysql in which a person (on LAN) use his usrname and password to login(only a single usrname and pass would be enough) and after the successful login the next page would be an editor where that person enters few sentences and then saves it. next time when that person logins to this page the last information that he put on the page should be mentioned with time and date.and this time if he enters new info, this new info should also be saved with the above text . i m totaly new to php/mysql.but i m sure if you guys help me i'll make it possible.i m running a linux m/c. so didnt find any clue to start this assignment. is there any script in php that can save only one username and pass for authentication and then move to next page(the editor). plz guide me what to do.. Quote Link to comment Share on other sites More sharing options...
chronister Posted March 5, 2007 Share Posted March 5, 2007 Although I will not write it for you, I will help guide you. http://www.php.net/manual/en/index.php is the location of the manual for php. Loads of questions and problems can be answered or solved there. I also sincerely suggest you read a book or at least some tutorials online and get familiar with the php language. You have the form that a person can login with and a switch statement to do something with the data received. How many users are there going to be? If there are a only a couple, then you could hard code the username / password into the page (not recommended though). If there are more than a couple (the recommended way of doing it) you should use a mysql table to store the username and password. (I am assuming this is a kind of article or news system) So create a couple tables in mysql. Once called users, and another called articles or news or whatever you want it to be called. In the users table create 3 fields.... user_id, username, password (possibly more if you want to store more info about users) Make sure you store an encrypted version of the password. the md5() function is what I use. In the other table, create these fields. user_id, article_id, date, article_text (possibly more if you want to store more data.) Scratch the whole switch statement, at least for how it's used. I would comment it out for now. Place a /* before the word switch and then place */ right before the ?>. You are going to have to use the $_POST[] superglobal to grab the username and password from the form that's submitted.e.g. $name = mysql_real_escape_string($_POST['name']); $passin = mysql_real_escape_string($_POST['passin']); This sets the username and password as these variables. The mysql_real_escape_string() thats surrounding the $_POST[] is used to prevent hackers from performing SQL Injection attacks Once you have the username and password, then you will need to query the database and use a SELECT query to find the user who's username and password matches what was submitted. Once that users data is found, then you will start a session and register the session variable. e.g. <?php session_start() $_SESSION['user'] = $username; // stores the username for use through the pages $_SESSION['user_id']= $user_id; // stores the users id for use through the pages ?> Start with that.... It's really late and I am really tired. Do what you can with the information I have provided and post back if ya get stuck or once you have accomplished these tasks and then we will move to the next part Regards, Nate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.