farkewie Posted October 27, 2006 Share Posted October 27, 2006 Ok...I have created a small sight with a heap of photos of my friends and i out and about so everyone can see them (friends) not just the person who has the camera.What i want is my index page to be a login/register page where the user can either log in with existing details or click register enter a certain amount of details eg: first name, last name and email pick a username and passwordThe e-mail gets sent to me [email protected] using my SMTP server mail.mysite.com i click a link and they get the confirmation email saying hey you good to go.I install a gallery on my server (using the web interface) and that has the exact feature i want except is uses its upload feature where i just want it give people access to my pages.Ive never worked with this sort of thing a point into he right direction with the easiest instructions would be appreciatedThanks Tyron Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/ Share on other sites More sharing options...
jwk811 Posted October 27, 2006 Share Posted October 27, 2006 heres a complete membership tutorial which is what you are looking for http://www.phpfreaks.com/tutorials/40/0.php Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-115450 Share on other sites More sharing options...
farkewie Posted October 28, 2006 Author Share Posted October 28, 2006 ok thanks heaps it should get me started only one question with the phpadmin, i have downloaded and unziped it in my local machine i will ftp it on to the server do i put it in to its own dir or extract it directly in to /public_html? ie;www.mysite.com/public_html/phpadmin\(here)?orwww.mysite.com/public.html/(here)?thanks heaps for your help im kind of strugleing with the learn as you go thing.... Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-115695 Share on other sites More sharing options...
jwk811 Posted October 28, 2006 Share Posted October 28, 2006 im not sure about that.. mine came with the hosting and domain i got.. anyone else know? and whos heaps? lol Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-115848 Share on other sites More sharing options...
farkewie Posted October 28, 2006 Author Share Posted October 28, 2006 Ok.. found it after hours of playing trying to install it.had a lot of trouble trying follow that tut though i have all the files i just dont know how to put them together to create a web log in out of it..is there anything i can install on to the server that covers it? i have found one but it just seems to allow users to register without me activating them? Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-115915 Share on other sites More sharing options...
jwk811 Posted October 29, 2006 Share Posted October 29, 2006 feel free to email me with the problems you're having and i will try to help you out.. ive been through that whole thing with the membership and just a couple days ago i got it all to work just fine.. Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-116150 Share on other sites More sharing options...
farkewie Posted October 29, 2006 Author Share Posted October 29, 2006 hey thanks heaps for your help so far. i became i bit smarter.. i downloaded the php help.chm think its my new best friend.i have everything working except for my login form. i have a very basic page so far and when i put in the username and password it just comes back to the same page saying "[color=red][font=Verdana][font=Verdana]Please enter ALL of the information![/font][/font][/color]"im not sure what im doing wrong? here is the code for the login page. (sorry about the size)[code]<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Tyspics - login</title><style type="text/css"><!--body { background-color: #0099FF;}.style1 {font-family: Georgia, "Times New Roman", Times, serif}--></style></head><body><form action="checkuser.php" method="post"> <table width="974" height="272" border="0" align="center"> <tr> <td width="360"> </td> <td width="305" height="41"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="75" hspace="50%" align="middle"> <param name="movie" value="FLASH/logo.swf" /> <param name="quality" value="high" /> <embed src="FLASH/logo.swf" width="200" height="75" hspace="50%" align="middle" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed> </object></td> <td width="295" rowspan="4"> </td> </tr> <tr> <td> </td> <td height="38">Username: <? echo $username; ?> <input type="text" name="textfield" /></td> </tr> <tr> <td> </td> <td>Password: <? echo $password; ?> <input type="password" name="textfield2" /></td> </tr> <tr> <td> </td> <td height="36" align="center"><input type="submit" name="Submit" value="Submit" /></td> </tr> <tr> <td> </td> <td height="38"><div align="center"> <h2><span class="style1"><a href="join_form.html">Register</a></span></h2> </div></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table></form></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-116320 Share on other sites More sharing options...
farkewie Posted October 30, 2006 Author Share Posted October 30, 2006 ok so i now have that fixed it was this little piece here [code]<input type="password" name="textarea" />[/code]it should have been..[code] <input type="password" name="password" />[/code]but now i have the pages up but it is not authenticating me? and when it kicks me back to the login page it is displaying info about my table. feel free to go and give it a try let me know what you tink it is?www.tyspics.com Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-116706 Share on other sites More sharing options...
jwk811 Posted October 30, 2006 Share Posted October 30, 2006 how you doin so far? where are you at? Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-116984 Share on other sites More sharing options...
farkewie Posted October 31, 2006 Author Share Posted October 31, 2006 getting there but im still stuck on the same thing.. i can register but i cant log in i put username and password in the text fields but when i press submitit comes back to the login page and says up the top left hand side [b]You could not be logged in! Either the username and password do not match or you have not validated your membership!Please try again![/b]and next to the username box it echo's my username and above the password it shows the md5 hash??same thin happens when i try the recover password function? feel free to go register and see what i mean.. <a href="http://tyspics.com/>here</a> thanks for all your help so far. never even looked at php before this but im starting to understand it i bit now.i think it has something to do with my checkuser.php ill post the code because ive been staring at it for a day now and i just cant work it out.[code]<? /* Check User Script */ session_start(); // Start Session include 'db.php'; // Conver to simple variables $username = $_POST['username']; $password = $_POST['password']; if((!$username) || (!$password)){ echo "Please enter ALL of the information! <br />"; include 'login_form.html'; exit(); } // Remove HTML (if any)$Username = strip_tags("$Username");$Password = strip_tags("$Password");// Convert password to md5 hash $password = md5($password); // check if the user info validates the db $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); } // Register some session variables! session_register('first_name'); $_SESSION['first_name'] = $first_name; session_register('last_name'); $_SESSION['last_name'] = $last_name; session_register('email_address'); $_SESSION['email_address'] = $email_address; session_register('special_user'); $_SESSION['user_level'] = $user_level; mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'"); header("Location: login_success.php"); } } else { echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br /> Please try again!<br />"; include 'login_form.html'; } ?> [/code]thanks Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-117105 Share on other sites More sharing options...
farkewie Posted October 31, 2006 Author Share Posted October 31, 2006 hey scrap that one too..lol i found a much better fix. ill post in case someone else has my problems.My was in the [code] $password = md5($password); [/code] just would not convert so i deleted it removed the code in the register.php about create random password. and adjusted the code to allow the user to create a password now all i have to do is workout how to have a confirm password field and make it do an error check and also have the activate email sent to me where i click a link it activates the account and sends them an email with there user name password and link to site....(getting there). oh i forgot the recover password still doesn't work when you press submit it just displays the email you types on the page next to the texfield.?? infact i think it does that when you enter the wrong paassword when logging in to??thanks heaps for your help [b]jwk811[/b] Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-117332 Share on other sites More sharing options...
jwk811 Posted November 1, 2006 Share Posted November 1, 2006 you'll still have to do the md5($password); thing when the user creats the password.. the whole point of it is so its safe and cant be viewed by people.. i had a problem with that same thing and im wondering if its the same problem.. the md5 thing changes the db password into a 32 letter/numbers. You might have a space in that row for only 25 characters where it should be set to at least 32.. i think you should do it this way instead of having the user chose their own cause now as you said the recover password thing isnt working.. let me know if this was the problem.. and if you're still having trouble or not Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-117657 Share on other sites More sharing options...
farkewie Posted November 1, 2006 Author Share Posted November 1, 2006 yeah thanks but i really want users to beable to choose there password so they can remember it.i have got that so far now i am just trying to adjust the mailing so that i am the one that activates the membership.i just did a test so i may have it now. but im still getting the problem of detailes being made visible when there are user input errors:[b]screen shot:[/b] http://www.tyspics.com/screenshot.htmland the recover password function doesn't bring back errors anymore but it sends and email to whatever email address you put in there but doesn't show the password? ill go back to that one soon i mainly just want to iron the bugs out of this register and activate. Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-117668 Share on other sites More sharing options...
jwk811 Posted November 1, 2006 Share Posted November 1, 2006 if you give me some code and you tell me what you want to happen ill try and fix it up to do so Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-118049 Share on other sites More sharing options...
farkewie Posted November 2, 2006 Author Share Posted November 2, 2006 Ok what im trying to do is this:user registers-->i receive email with there name, email and username also a link to activate them. i click the link it activates them and sends them an email with there username and password that they chose and a link to login. below are my code samples.register.php (this bit seems to work it enters them in to the data base and sends me a link to activate][code]<?phpinclude 'db.php'; // Define post fields into simple variables $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_address = $_POST['email_address']; $username = $_POST['username']; $password = $_POST['password'];$info = $_POST['info']; /* Let's strip some slashes in case the user entered any escaped characters. */ $first_name = stripslashes($first_name); $last_name = stripslashes($last_name); $email_address = stripslashes($email_address); $username = stripslashes($username); $info = stripslashes($info); $password = stripslashes($password); /* Do some error checking on the form posted fields */ if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){ echo 'You did not submit the following required information! <br />'; if(!$first_name){ echo "First Name is a required field. Please enter it below.<br />"; } if(!$last_name){ echo "Last Name is a required field. Please enter it below.<br />"; } if(!$email_address){ echo "Email Address is a required field. Please enter it below.<br />"; } if(!$username){ echo "Desired Username is a required field. Please enter it below.<br />"; } include 'join_form.html'; // Show the form again! /* End the error checking and if everything is ok, we'll move on to creating the user account */ exit(); // if the error checking has failed, we'll exit the script! } /* Let's do some checking and ensure that the user's email address or username does not exist in the database */ $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'"); $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $email_check = mysql_num_rows($sql_email_check); $username_check = mysql_num_rows($sql_username_check); if(($email_check > 0) || ($username_check > 0)){ echo "Please fix the following errors: <br />"; if($email_check > 0){ echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />"; unset($email_address); } if($username_check > 0){ echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />"; unset($username); } include 'join_form.html'; // Show the form again! exit(); // exit the script so that we do not create this account! } /* Everything has passed both error checks that we have done. It's time to create the account! */ /* Random Password generator. http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php We'll generate a random password for the user and encrypt it, email it and then enter it into the db. */ $db_password = ($password); // Enter info into the Database. $info2 = htmlspecialchars($info); $sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date) VALUES('$first_name', '$last_name', '$email_address', '$username', '$db_password', '$info2', now())") or die (mysql_error()); if(!$sql){ echo 'There has been an error creating your account. Please contact the webmaster.'; } else { $userid = mysql_insert_id(); //----------------------------------$to = "[email protected]"; /* change this! */$subject = "Registration at tyspics.com'"; /* change this! */$recipientSubject = "Registration at tyspics.com"; /* change this! */$receiptMessage = "Thank you ".$firstName." Your account will be ready to go when i get home\n\n" ."--------CONTACT--------\n" ."First Name: ".$first_Name."\n" ."Last Name: ".$last_Name."\n" ."E-mail: ".$email_address."\n" ."username: ".$username."\n" ."To activate your membership, please click here: http://www.tyspics.com/activate.php?id=$userid&code=$db_password";mail($to, $recipientSubject, $receiptMessage);}include 'login_form.html';?>[/code]activate.php this aslo seems to work.. its activates them in the database[code]<?php/* Account activation script */ // Get database connection include 'db.php'; // Create variables from URL. $userid = $_REQUEST['id']; $code = $_REQUEST['code']; $sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'"); $sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'"); $doublecheck = mysql_num_rows($sql_doublecheck); if($doublecheck == 0){ echo "<strong><font color=red>Your account could not be activated!</font></strong>"; } elseif ($doublecheck > 0) { echo "<strong>Your account has been activated!</strong> You may login below!<br />"; include 'mail.php'; }?>[/code]and then the one that just wont play.. mail.php (supposed to send user an email.[code]<?php// Get database connection include 'db.php'; $subject = "Your Membership at Tyspics.com"; $message = "Dear $first_name $last_name, OI! i'll get you a password when i get home. You are two steps away from logging in and accessing our exclusive members area. Once you activate your memebership, you will be able to login with the following information: Username: $username Password: $password Thanks! The Webmaster This is an automated response, please do not reply!"; mail($email_address, $subject, $message, "From: tyspics Webmaster<[email protected]>\n X-Mailer: PHP/" . phpversion()); echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!'; ?> [/code]after all that the mail doesn't work but i don't get any errors so i have a feeling that its just not getting the email address properly. just a hunch???Thank you Link to comment https://forums.phpfreaks.com/topic/25323-first-time-php-tryng-to-creat-simple-loginregister-page/#findComment-118258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.