This is a discussion on User Accounts managemant within the PHP General forums, part of the PHP Programming Forums category; I am new to all this php script stuff. I was wanting to create a website that would have phpauction ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am new to all this php script stuff. I was wanting to create a
website that would have phpauction but i was also wanting to run several other php scripts like a calender and a directory and possibly several other scripts. I was wondering if there is a way that a user could set up one account and it would automatically create account in all the scripts this would allow users to keep the same user account for all services. Does that makes sense. I just want people to enter their information once and then they would be would have accounts for all the services thanks. |
|
|||
|
Try adding this line to all services:
<? include_once('login.php'); ?> login.php: <? mysql_connect($db["host"], $db["user"], $db["pass"]) or die("MySQL error"); mysql_select_db($db["admin"]) or die("MySQL error"); session_start(); if($action=="logout") { session_unregister('name'); session_unregister('passwd'); exit("You have been logged out.<br><a href=\"".$PHP_SELF."\">Log in as another user.</a>"); } if (!isset($name) && !isset($pass)) { exit("<form name=\"login\" action=\"".$PHP_SELF."\" method=\"post\"> <input name=\"name\" type=\"text\" value=\"\"><br> <input name=\"passwd\" type=\"password\" value=\"\"><br> <input type=\"submit\" value=\"Log in\"> </form>"); } else { session_register('name'); $_SESSION['name'] = $name; session_register('passwd'); $_SESSION['passwd'] = $passwd; $query="SELECT pass FROM `users` WHERE `username`='".$_SESSION['name']."' LIMIT 0, 30"; $row=mysql_fetch_array(mysql_query($query)); $pass=$row["pass"]; if($_SESSION['name']==$name and md5($_SESSION['passwd'])==$pass) { echo "<p align=\"right\">User: [".$name."]<br><a href=\"".$PHP_SELF."?action=logout\">Log Out</a></p>"; } else { session_unregister('name'); session_unregister('passwd'); exit(" <form name=\"login\" action=\"".$PHP_SELF."\" method=\"post\"> <input name=\"name\" type=\"text\" value=\"\"><br> <input name=\"passwd\" type=\"password\" value=\"\"><br> <input type=\"submit\" value=\"Log in\"> </form>"); } } ?> |