Luke101
06-20-2006, 06:38 PM
I was told that i needed to use PHP for login form. Do i really? Can you place the code i need. I DONT KNOW A CODE!
|
Click to See Complete Forum and Search --> : Login Area Luke101 06-20-2006, 06:38 PM I was told that i needed to use PHP for login form. Do i really? Can you place the code i need. I DONT KNOW A CODE! scottyrob 06-21-2006, 01:46 AM I dont think you will get much response if you cannot even be bothered to try! If you cant be bothered to try, search google for some pre-made ones. If you want to try and make it yourself, im sure we will all be more than happy to help! Fet NogDog 06-21-2006, 06:13 AM No, you don't have to use PHP, specifically. You do need to use some sort of server-side processing, and if your web server supports it then PHP would be a good option, but it's certainly not the only good option. Whatever option you choose, it's not just a question of posting a few lines of code for you to copy-and-paste. For one thing there's also the set-up of the database (or other data source) where user login data will be stored. As stated above, searching the various script repository sites will find many pre-made solutions (of various quality from excellent to crappy), but asking us to simply write one for you probably is not going to get much response here. Luke101 06-21-2006, 03:35 PM I dont think you will get much response if you cannot even be bothered to try! If you cant be bothered to try, search google for some pre-made ones. If you want to try and make it yourself, im sure we will all be more than happy to help! Fet >_< _____________ Oh great william232 06-22-2006, 04:18 PM hey,man the only way to learn is by looking at tutorals :) Luke101 08-01-2006, 08:12 PM :( NogDog 08-01-2006, 08:41 PM Follow the link in my sig for one login control option. PJStew 08-02-2006, 06:27 AM I have some code I use to do this, it's a MySQL database and table, with a PHP add new user, and a PHP login. i'll post it up when i get home. I think every one is right with saying you should have a go, then we'll all help. I started learning PHP because I needed a login, and found all the info i needed from other treads on this forum, and lots of help from everyone. :) PJStew 08-02-2006, 01:11 PM ok, here you go. I've got this on my home page. index.php <?php session_start(); ?> <?php if( ! session_is_registered("username") ) { echo("<form action=\"authenticate5.php\" method=\"post\"> Username:<br /> <input type=\"text\" name=\"username\" size=\"12\" /> <br /> Password:<br /> <input type=\"password\" name=\"password\" size=\"12\" /> <br /> <input type=\"submit\" value=\"Log In\" /> </form></p><span class=\"style4\"><a href=\"create_user.php\">Create account</a></span>"); } else { echo("<span class=\"style4\">User Name: $username <a href=\"logout2.php\">LogOut</a></span>"); } ?> authenticate5.php <?php if( (!$username) or (!$password) ) { header("Location:http://localhost/Dinamic%20uni/Unicycle/index.php"); exit(); } $conn=@mysql_connect("localhost", "username", "password") or die("Could not connect"); $rs = @mysql_select_db("my_database", $conn) or die("could not select database"); $sql="select * from users where user_name=\"$username\" and password = password( \"$password\" )"; $rs=mysql_query($sql,$conn) or die("Could not execute query"); $num = mysql_numrows($rs); if($num != 0) { session_start(); session_register("username"); $username = $username; header("LOCATION:http://localhost/Dinamic%20uni/Unicycle/index.php"); } else { header("Location:http://localhost/Dinamic%20uni/Unicycle/index.php"); exit(); } ?> create_user.php <?php if( (!$_POST['firstname']) or (!$_POST['lastname']) or (!$_POST['username']) or (!$_POST['password']) ) { $form ="<p>Please enter all new user details.</p>"; $form.="<form action=\"$PHP_SELF\""; $form.=" method=\"post\">First Name:<br /> "; $form.="<input type=\"text\" name=\"firstname\""; $form.=" value=\"$firstname\"><br />Last Name:<br /> "; $form.="<input type=\"text\" name=\"lastname\""; $form.=" value=\"$lastname\"><br />User Name:<br /> "; $form.="<input type=\"text\" name=\"username\""; $form.=" value=\"$username\"><br />Password:<br /> "; $form.="<input type=\"text\" name=\"password\""; $form.=" value=\"$password\"><br /><br />"; $form.="<input type=\"submit\" value=\"Submit\">"; $form.="</form>"; echo($form); } else { $conn = mysql_connect("localhost","username","password") or die("Could not connect to MySQL"); $db = mysql_select_db("my_database",$conn) or die("Could not select database"); $sql = "insert into `users` (`first_name`,`last_name`,`user_name`,`password`) values (\"$firstname\",\"$lastname\",\"$username\",password(\"$password\") )"; $result = mysql_query($sql,$conn) or die(mysql_error()); if($result) { echo("New user $username added"); } } ?> and MySQL database is called my_database and looks like this. mysql> use my_database; Database changed mysql> explain users; +------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+-------+ | first_name | varchar(50) | YES | | NULL | | | last_name | varchar(50) | YES | | NULL | | | user_name | varchar(25) | YES | UNI | NULL | | | password | varchar(41) | YES | | NULL | | +------------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) mysql> Luke101 08-04-2006, 07:53 PM :) PJStew 08-05-2006, 06:16 AM did that solve it for you? :) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |