943,708 Members | Top Members by Rank

Ad:
You are currently viewing page 6 of this multi-page discussion thread; Jump to the first page
Jun 26th, 2009
0

Re: To create a registration page and login page

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. ;_;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sethron is offline Offline
2 posts
since Jun 2009
Jun 28th, 2009
-1

Re: To create a registration page and login page

Click to Expand / Collapse  Quote originally posted by Sethron ...
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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Jul 17th, 2009
0

Re: To create a registration page and login page

Click to Expand / Collapse  Quote originally posted by macneato ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
neo1sxn is offline Offline
1 posts
since Jul 2009
Jul 20th, 2009
0

Re: To create a registration page and login page

For that work you should know the server side scripting language such as ASP.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
abhicary is offline Offline
3 posts
since Jul 2009
Jul 22nd, 2009
0

Re: To create a registration page and login page

Click to Expand / Collapse  Quote originally posted by abhicary ...
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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Paollo is offline Offline
16 posts
since Jun 2009
Sep 26th, 2009
0

Re: To create a registration page and login page

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





Click to Expand / Collapse  Quote originally posted by macneato ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pcdoctor25 is offline Offline
4 posts
since Sep 2009
Sep 27th, 2009
0

Re: To create a registration page and login page

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.
Reputation Points: 70
Solved Threads: 15
Posting Whiz
kanaku is offline Offline
378 posts
since Jan 2007
Sep 27th, 2009
0

Re: To create a registration page and login page

Thank you very much, that helps alot.

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




Click to Expand / Collapse  Quote originally posted by kanaku ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pcdoctor25 is offline Offline
4 posts
since Sep 2009
Sep 30th, 2009
0

Re: To create a registration page and login page

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pcdoctor25 is offline Offline
4 posts
since Sep 2009
Sep 30th, 2009
0

Re: To create a registration page and login page

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pcdoctor25 is offline Offline
4 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in HTML and CSS Forum Timeline: text moving in rectangular shape
Next Thread in HTML and CSS Forum Timeline: CSS float image and text inline with image





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC