Cyber1AS Posted January 6, 2007 Share Posted January 6, 2007 Im working on a website and i need help to know how to make accounts(members) and passwords on account, Is anyone avaiable to help me.Please contact meThank you. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/ Share on other sites More sharing options...
taith Posted January 6, 2007 Share Posted January 6, 2007 wow... um... vague...basically... you want a table in your database for users with a spot for a id/username/password/etc.then you have on your page a spot to login, which then pulls up the account, and saves the account in a session... Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154326 Share on other sites More sharing options...
Hypnos Posted January 6, 2007 Share Posted January 6, 2007 You want a script that checks to make sure the username isn't already taken, then builds a SQL insert command and sends it to your SQL server.At least, assuming you are using a SQL server. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154332 Share on other sites More sharing options...
jwk811 Posted January 7, 2007 Share Posted January 7, 2007 are you looking for how to create an entire membership system? if so heres a great tutorial that will walk you through it.. [url=http://www.phpfreaks.com/tutorials/40/4.php]http://www.phpfreaks.com/tutorials/40/4.php[/url] Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154579 Share on other sites More sharing options...
john010117 Posted January 7, 2007 Share Posted January 7, 2007 ...or you can simply download [url=http://www.phpbb.com]phpBB[/url]. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154759 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 [quote]...or you can simply download phpBB.[/quote]Um... isn't phpBB a bulletin board? Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154767 Share on other sites More sharing options...
marcus Posted January 7, 2007 Share Posted January 7, 2007 Just do:CREATE TABLE `users` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`username` VARCHAR( 255 ) NOT NULL ,`password` VARCHAR( 255 ) NOT NULL ,`email` VARCHAR( 255 ) NOT NULL ,`ip` VARCHAR( 255 ) NOT NULL ,`confirm` INT NOT NULL DEFAULT '0' ,`confirm2` INT ( 75 ) NOT NULL) ENGINE = MYISAM ;And then make a file called form.php //will store your form.[code=php:0]<?phpecho "<form name=register method=post action=register.php>\n <table border=0 cellspacing=3 cellpadding=2>\n <tr><td> Username:</td> <td><input type=text name=username></td> </tr> <tr><td> Password:</td> <td><input type=password name=pass1></td> </tr> <tr><td> Confirm:</td> <td><input type=password name=pass2></td> </tr> <tr><td> Email:</td> <td><input type=text name=email1></td> </tr> <tr><td> Confirm:</td> <td><input type=text name=email2></td> </tr> <tr><td colspan=2> <input type=hidden name=act value=register> <input type=submit value=Register> </td></tr> </table> </form>";?>[/code]Then we'll make register.php[code=php:0]<?php $act = $_POST['act']; if(!isset($act)){ //you could do empty($act) include_once('form.php'); die(); } if($act == register){ $username = $_POST['username']; $password = md5($_POST['pass1']); $confpwrd = md5($_POST['pass2']; $email = $_POST['email1']; $confemal = $_POST['email2']; if(isset($username) && isset($password) && isset($confpwrd) && isset($email) && isset($confemal)){ //will check for password equaling if($password != $confpwrd){ echo "<b>Your passwords did not match!</b><br><br>"; include_once('form.php'); die(); } //will check length of pw if(str_len($_POST['pass1']) < 6){ echo "<b>Your password was too short!</b><br><br>"; include_once('form.php'); die(); } //will check for email equaliing (wont go into correct email syntax if they want to register then they shall confirm it if($email != $confemal){ echo "<b>Your email addresses did not match!</b><br><br>"; include_once('form.php'); die(); } //checking if user name exists $sql = "SELECT `username` FROM `users` WHERE `username` ='$username'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 1){ echo "<b>The username $username is already in use!</b><br><br>"; include_once('form.php'); die(); } //if does exist check length if(str_len($username) < 4){ echo "<b>The username you entered was too short!</b><br><br>"; include_once('form.php'); die(); } //will check if IP already exists $sql = "SELECT `ip` FROM `users` WHERE `ip` ='$_SERVER[REMOTE_ADDR]'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 1){ echo "<b>Your IP Address is already in use!</b><br><br>"; include_once('form.php'); die(); } //if everything is good then we will insert into the database $rand = mt_rand(10,30); $sql = "INSERT INTO `users` (`username`,`password`,`email`,`ip`,`confirm`,`confirm2`) VALUES('$username','$password','$email','$_SERVER[REMOTE_ADDR]','0','$rand')"; $res = mysql_query($sql) or die(mysql_error()); if($res){ echo "<b>Thank you for registering!</b>"; //now will send email to the person with confirmation link $message = "Confirmation for yoursitenamehere http://yoursitename.com/confirm.php?num=$rand"; $headers .= 'From: yoursitename <[email protected]>\r\n'; $headers .= 'Reply-To: yoursitename <[email protected]>\r\n'; $headers .= 'Return-Path: yoursitename <[email protected]>\r\n'; $headers .= "X-Mailer: PHP v".phpversion(); $mail = mail($email,'WebsiteName Confirmation',$message,$headers); } }else { echo "<b>You did not fill out all the information!</b><br><br>\n"; include_once('form.php'); die(); }?>[/code]Then make a file called confirm.php[code=php:0]<?php$num = $_GET['num']; if(!isset($num)){ //could use empty($num) echo "You did not specify a confirmation code!"; }else { $sql = "SELECT * FROM `users` WHERE `confirm2` ='$num'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); if($row[confirm] == 1){ echo "<b>This account has already been confirmed!"; }else { $sql = "UPDATE `users` SET `confirm` =1"; $res = mysql_query($sql) or die(mysql_error()); if($res){ echo "<b>Your account $row[username] has been confirmed!</b>"; } } }?>[/code]I haven't tested it, I just made it, so yeah. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154798 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 mgallforever, you desperately need to learn how to indent your code in logical blocks, its very difficult to read. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154800 Share on other sites More sharing options...
marcus Posted January 7, 2007 Share Posted January 7, 2007 I've been trying the best I could since you told me that like a couple months ago, haha. Link to comment https://forums.phpfreaks.com/topic/33123-does-anyone-know-how-to-make-users-and-accounts-on-a-website/#findComment-154801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.