| | |
To create a registration page and login page
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 2
Reputation:
Solved Threads: 0
HTML and CSS Syntax (Toggle Plain Text)
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. ;_;
•
•
•
•
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. ;_;
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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.
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.
•
•
Join Date: Jun 2009
Posts: 16
Reputation:
Solved Threads: 1
Invisible Yahoo- Detect who is invisible in your Yahoo! Messenger list and Hi5. | Link Exchange | Hidroizolatii
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
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
Pcdoctor25
•
•
•
•
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)
<? // Replace the variable values below // with your specific database information. $host = "localhost"; $user = "UserName"; $pass = "Password"; $db = "dbName"; // This part sets up the connection to the // database (so you don't need to reopen the connection // again on the same page). $ms = mysql_pconnect($host, $user, $pass); if ( !$ms ) { echo "Error connecting to database.\n"; } // Then you need to make sure the database you want // is selected. mysql_select_db($db); ?>
Registration name this file "register.php"
HTML and CSS Syntax (Toggle Plain Text)
<?php // dbConfig.php is a file that contains your // database connection information. This // tutorial assumes a connection is made from // this existing file. include ("dbConfig.php"); //Input vaildation and the dbase code if ( $_GET["op"] == "reg" ) { $bInputFlag = false; foreach ( $_POST as $field ) { if ($field == "") { $bInputFlag = false; } else { $bInputFlag = true; } } // If we had problems with the input, exit with error if ($bInputFlag == false) { die( "Problem with your registration info. " ."Please go back and try again."); } // Fields are clear, add user to database // Setup query $q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) " ."VALUES ('".$_POST["username"]."', " ."PASSWORD('".$_POST["password"]."'), " ."'".$_POST["email"]."')"; // Run query $r = mysql_query($q); // Make sure query inserted user successfully if ( !mysql_insert_id() ) { die("Error: User not added to database."); } else { // Redirect to thank you page. Header("Location: register.php?op=thanks"); } } // end if //The thank you page elseif ( $_GET["op"] == "thanks" ) { echo "<h2> Thanks for registering!</h2> "; } //The web form for input ability else { echo "<form action=\"?op=reg\" method=\"POST\"> \n"; echo "Username: <input name=\"username\" MAXLENGTH=\"16\"> <br /> \n"; echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"> <br /> \n"; echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"> <br /> \n"; echo "<input type=\"submit\"> \n"; echo "</form> \n"; } // EOF ?>
Login name this file "login.php"
HTML and CSS Syntax (Toggle Plain Text)
<?php session_start(); // dBase file include "dbConfig.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `dbUsers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: members.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information."); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?>
Members Area name this file "members.php", and include on pages that are only for registered users
HTML and CSS Syntax (Toggle Plain Text)
?php session_start(); if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: login.php"); } // Member only content // ... // ... // ... // Display Member information echo "<p>User ID: " . $_SESSION["valid_id"]; echo "<p>Username: " . $_SESSION["valid_user"]; echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]); // Display logout link echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?>
logout name this file "logout.php"
HTML and CSS Syntax (Toggle Plain Text)
<?php session_start(); session_unset(); session_destroy(); // Logged out, return home. Header("Location: index.php"); ?>
There you go... need more help or confused, just ask.
If this information solved your problem. Please add to my reputation.
Thanks
macneato
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.
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.
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.
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
Thank you very much, that helps alot.
------------------
The company im building for wants numbers ad id login.
------------------
The company im building for wants numbers ad id login.
•
•
•
•
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.
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
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.
Thanks in advance for your help i am new to php.
![]() |
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- How to create a login page using ASp.net 2.0 c# (ASP.NET)
- Create a Login page (asp,c#,sql2k5) (C#)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Error message when running ASP login page (ASP)
Other Threads in the HTML and CSS Forum
- Previous Thread: web form handler code
- Next Thread: Problem using Div tags and css in dreamweaver?
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form google griefers hackers hitcounter hover html ie7 ie8 iframe image images internet intranet iphone javascript jpeg layout macbook maps mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning scroll seo shopping swf swf. textcolor timecolor titletags url urlseparatedwords visualization web webdevelopment webform website windows7






