To create a registration page and login page

Reply

Join Date: Jun 2009
Posts: 2
Reputation: Sethron is an unknown quantity at this point 
Solved Threads: 0
Sethron Sethron is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #51
Jun 26th, 2009
HTML and CSS Syntax (Toggle Plain Text)
  1. I'm very lost as to what's going wrong. Everything else that I've found in this place seems to have been fine, but it says it has a syntax error at the lines (in both login.php and register.php) where there is die ( "So on and so forth here" )
  2.  
  3. ... I don't understand why it's having a problem. ;_;
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,210
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: To create a registration page and login page

 
-1
  #52
Jun 28th, 2009
Originally Posted by Sethron View Post
I'm very lost as to what's going wrong. Everything else that I've found in this place seems to have been fine, but it says it has a syntax error at the lines (in both login.php and register.php) where there is die ( "So on and so forth here" )

... I don't understand why it's having a problem. ;_;
Full problem description will be highly beneficial as above doesn't make sense
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: neo1sxn is an unknown quantity at this point 
Solved Threads: 0
neo1sxn neo1sxn is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #53
Jul 17th, 2009
Originally Posted by macneato View Post
With the password field. Change the type to varchar(25)

As for requesting passwords.

Yes. It can be done.
Ask the user to enter their email address.
select password from your_db where email_address = 'their_address'
Use the mail() function to send the password to the email address.

SQL:
SELECT
dbusers.password
FROM
dbusers
WHERE
(dbusers.email = 'pforgot')

'pforgot' is any name you've given to the form text input. Will write up a full script as soon as i get time. It's monday morning.. Things are a little hectic.
macneato sir ,

I have make my website totaly in html formate sir show me a way , i want to setup sign up and login feature so that my visitors can not download anything without signup...please sir reply me on my email my email is <EMAIL SNIPPED>please sir i m waiting for your reply.
Last edited by peter_budo; Jul 18th, 2009 at 12:46 pm. Reason: Keep It On The Site - Do not post asking for an answer to be sent to you via email or PM.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 3
Reputation: abhicary is an unknown quantity at this point 
Solved Threads: 0
abhicary abhicary is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #54
Jul 20th, 2009
For that work you should know the server side scripting language such as ASP.
Abhi Cary HID Ballast
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 16
Reputation: Paollo is an unknown quantity at this point 
Solved Threads: 1
Paollo Paollo is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #55
Jul 22nd, 2009
Originally Posted by abhicary View Post
For that work you should know the server side scripting language such as ASP.
Isn't there any simpler way? something only in html language? or only by a script introduced in html? I mean something very basic, no advanced futures required.
Invisible Yahoo- Detect who is invisible in your Yahoo! Messenger list and Hi5. | Link Exchange | Hidroizolatii
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: pcdoctor25 is an unknown quantity at this point 
Solved Threads: 0
pcdoctor25 pcdoctor25 is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #56
Sep 26th, 2009
I need the user name to be numbers only is there a special code that i need to put in for the database and register page?

Pcdoctor25





Originally Posted by macneato View Post
Simple PHP login:

Create a database (mysqladmin)

Name the table "dbUsers." It will need 4 fields:

Name Type Addition
id int(10) Primary Key, AUTO_INCREMENT
username varchar(16) Unique
password char(16)
email varchar(25)


Create a new file and name it dbConfig.php This will file will connect to the database

HTML and CSS Syntax (Toggle Plain Text)
  1. <?
  2. // Replace the variable values below
  3. // with your specific database information.
  4. $host = "localhost";
  5. $user = "UserName";
  6. $pass = "Password";
  7. $db = "dbName";
  8.  
  9. // This part sets up the connection to the
  10. // database (so you don't need to reopen the connection
  11. // again on the same page).
  12. $ms = mysql_pconnect($host, $user, $pass);
  13. if ( !$ms )
  14. {
  15. echo "Error connecting to database.\n";
  16. }
  17.  
  18. // Then you need to make sure the database you want
  19. // is selected.
  20. mysql_select_db($db);
  21. ?>

Registration name this file "register.php"

HTML and CSS Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. // dbConfig.php is a file that contains your
  4. // database connection information. This
  5. // tutorial assumes a connection is made from
  6. // this existing file.
  7. include ("dbConfig.php");
  8.  
  9.  
  10. //Input vaildation and the dbase code
  11. if ( $_GET["op"] == "reg" )
  12. {
  13. $bInputFlag = false;
  14. foreach ( $_POST as $field )
  15. {
  16. if ($field == "")
  17. {
  18. $bInputFlag = false;
  19. }
  20. else
  21. {
  22. $bInputFlag = true;
  23. }
  24. }
  25. // If we had problems with the input, exit with error
  26. if ($bInputFlag == false)
  27. {
  28. die( "Problem with your registration info. "
  29. ."Please go back and try again.");
  30. }
  31.  
  32. // Fields are clear, add user to database
  33. // Setup query
  34. $q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
  35. ."VALUES ('".$_POST["username"]."', "
  36. ."PASSWORD('".$_POST["password"]."'), "
  37. ."'".$_POST["email"]."')";
  38. // Run query
  39. $r = mysql_query($q);
  40.  
  41. // Make sure query inserted user successfully
  42. if ( !mysql_insert_id() )
  43. {
  44. die("Error: User not added to database.");
  45. }
  46. else
  47. {
  48. // Redirect to thank you page.
  49. Header("Location: register.php?op=thanks");
  50. }
  51. } // end if
  52.  
  53.  
  54. //The thank you page
  55. elseif ( $_GET["op"] == "thanks" )
  56. {
  57. echo "<h2> Thanks for registering!</h2> ";
  58. }
  59.  
  60. //The web form for input ability
  61. else
  62. {
  63. echo "<form action=\"?op=reg\" method=\"POST\"> \n";
  64. echo "Username: <input name=\"username\" MAXLENGTH=\"16\"> <br /> \n";
  65. echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"> <br /> \n";
  66. echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"> <br /> \n";
  67. echo "<input type=\"submit\"> \n";
  68. echo "</form> \n";
  69. }
  70. // EOF
  71. ?>

Login name this file "login.php"
HTML and CSS Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3. // dBase file
  4. include "dbConfig.php";
  5.  
  6. if ($_GET["op"] == "login")
  7. {
  8. if (!$_POST["username"] || !$_POST["password"])
  9. {
  10. die("You need to provide a username and password.");
  11. }
  12.  
  13. // Create query
  14. $q = "SELECT * FROM `dbUsers` "
  15. ."WHERE `username`='".$_POST["username"]."' "
  16. ."AND `password`=PASSWORD('".$_POST["password"]."') "
  17. ."LIMIT 1";
  18. // Run query
  19. $r = mysql_query($q);
  20.  
  21. if ( $obj = @mysql_fetch_object($r) )
  22. {
  23. // Login good, create session variables
  24. $_SESSION["valid_id"] = $obj->id;
  25. $_SESSION["valid_user"] = $_POST["username"];
  26. $_SESSION["valid_time"] = time();
  27.  
  28. // Redirect to member page
  29. Header("Location: members.php");
  30. }
  31. else
  32. {
  33. // Login not successful
  34. die("Sorry, could not log you in. Wrong login information.");
  35. }
  36. }
  37. else
  38. {
  39. //If all went right the Web form appears and users can log in
  40. echo "<form action=\"?op=login\" method=\"POST\">";
  41. echo "Username: <input name=\"username\" size=\"15\"><br />";
  42. echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
  43. echo "<input type=\"submit\" value=\"Login\">";
  44. echo "</form>";
  45. }
  46. ?>

Members Area name this file "members.php", and include on pages that are only for registered users
HTML and CSS Syntax (Toggle Plain Text)
  1. ?php
  2. session_start();
  3.  
  4. if (!$_SESSION["valid_user"])
  5. {
  6. // User not logged in, redirect to login page
  7. Header("Location: login.php");
  8. }
  9.  
  10. // Member only content
  11. // ...
  12. // ...
  13. // ...
  14.  
  15. // Display Member information
  16. echo "<p>User ID: " . $_SESSION["valid_id"];
  17. echo "<p>Username: " . $_SESSION["valid_user"];
  18. echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]);
  19.  
  20. // Display logout link
  21. echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
  22. ?>

logout name this file "logout.php"
HTML and CSS Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3. session_unset();
  4.  
  5. session_destroy();
  6. // Logged out, return home.
  7. Header("Location: index.php");
  8. ?>

There you go... need more help or confused, just ask.

If this information solved your problem. Please add to my reputation.
Thanks
macneato
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 276
Reputation: kanaku is on a distinguished road 
Solved Threads: 15
kanaku's Avatar
kanaku kanaku is offline Offline
Posting Whiz in Training

Re: To create a registration page and login page

 
0
  #57
Sep 27th, 2009
Try the following,
1. Since you want the 'username' to be numbers, then your data type should be numeric or integers too, just like the id column.
in the Simple PHP login:

Create a database (mysqladmin)

Name the table "dbUsers." It will need 4 fields:

Name Type Addition
id int(10) Primary Key, AUTO_INCREMENT
username int(10) Unique
password char(16)
email varchar(25)

---------------

That's it, actually. Although I have to wonder why you're not using the 'id' column to identify the users instead if you're going to use numbers anyway.
If you know ASP, you can save other daniweb members from idiots like me by helping out in this forum.

Visit this thread
if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: pcdoctor25 is an unknown quantity at this point 
Solved Threads: 0
pcdoctor25 pcdoctor25 is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #58
Sep 27th, 2009
Thank you very much, that helps alot.

------------------
The company im building for wants numbers ad id login.




Originally Posted by kanaku View Post
Try the following,
1. Since you want the 'username' to be numbers, then your data type should be numeric or integers too, just like the id column.
in the Simple PHP login:

Create a database (mysqladmin)

Name the table "dbUsers." It will need 4 fields:

Name Type Addition
id int(10) Primary Key, AUTO_INCREMENT
username int(10) Unique
password char(16)
email varchar(25)

---------------

That's it, actually. Although I have to wonder why you're not using the 'id' column to identify the users instead if you're going to use numbers anyway.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: pcdoctor25 is an unknown quantity at this point 
Solved Threads: 0
pcdoctor25 pcdoctor25 is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #59
Sep 30th, 2009
I am using some html pages and php. Do I delete the html codes from the login.php and then just copy the php code into the page? I tried it both ways and when i preview the login.php page it shows the form feilds, but it also shows some of the php code, Im doing something wrong, Should I remove the instructions out of the code?

Thanks in advance for your help i am new to php.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: pcdoctor25 is an unknown quantity at this point 
Solved Threads: 0
pcdoctor25 pcdoctor25 is offline Offline
Newbie Poster

Re: To create a registration page and login page

 
0
  #60
Sep 30th, 2009
never mind I got it thank you, I copied the code but in dreamweaver it didnt number each line of code, so I had to copy and paste one at a time.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC