Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in PHP only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
PHP
Login Form
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
werks
New Member
Join Date:
Dec 2007
Posts:
218
#1
Login Form
Feb 13 '08, 02:10 PM
hi guy'z Im new in PHP could someone tell me how to create a Login form using PHP?
--
Kenneth
"Better Than Yesterday"
Markus
Recognized Expert
Expert
Join Date:
Jun 2007
Posts:
6092
#2
Feb 13 '08, 02:18 PM
Originally posted by
werks
hi guy'z Im new in PHP could someone tell me how to create a Login form using PHP?
--
Kenneth
"Better Than Yesterday"
google is your friend ;)
Comment
Post
Cancel
werks
New Member
Join Date:
Dec 2007
Posts:
218
#3
Feb 13 '08, 02:29 PM
Thanks for your advice..
--
Kenneth
"Better Than Yesterday"
Comment
Post
Cancel
harshmaul
Recognized Expert
Contributor
Join Date:
Jul 2007
Posts:
490
#4
Feb 13 '08, 03:19 PM
Hi werks, you can check this link out...
Creating a PHP CMS for administration
Comment
Post
Cancel
ronverdonk
Recognized Expert
Specialist
Join Date:
Jul 2006
Posts:
4259
#5
Feb 13 '08, 03:26 PM
For the last time then, here we go again, a simple form
[php]<?php
session_start() ;
// -------------------------------
// check if form is submitted
// -------------------------------
$error = false;
if (isset($_POST['_submit']) ) {
if (isset($_POST['userid']) AND isset($_POST['password'])) {
$uid = strip_tags($_PO ST['uid']);
$psw = strip_tags($_PO ST['psw']);
// ------------------------------------------------
// Check passed username and password in database
// ------------------------------------------------
// ......
// ..... connect to data base
// ......
// check existence of uid and psw in table
$res = mysql_query("SE LECT * FROM authorized_user s WHERE userid='$uid' AND passwd=sha1('$p sw')")
or die ("SELECT error: " . mysql_error());
if (mysql_num_rows ($res) != 1) {
$error = true;
}
else {
// ------------------------------------------------
// userid and psw valid, store userid in session
// ------------------------------------------------
$_SESSION['username'] = strip_tags($_PO ST['username']);
// ...........
// ===> continue processing valid user
// ===> ...........
}
}
else {
// ------------------------------------------------
// no userid and/or password specified, error
// ------------------------------------------------
$error = true;
}
}
// ------------------------------------------------------
// Display the login form (again)
// ------------------------------------------------------
print "<form name='authForm' method='POST' action='".$_SER VER['PHP_SELF']."'>";
if ($error == true) {
print "<p style='font-weight:bold;col or:red'>You have entered an invalid userid and/or password - try again</p>";
}
print "Username <input type='text' name='uid' value='$uid'> <br />";
print "Password <input type='password' name='psw' value='$psw'> <br />";
print '<input type="submit" name="login" value="Login" />';
print '<input type="hidden" name="_submit" value="1"/>';
print '</form>';
?>[/php]
Ronald
Comment
Post
Cancel
werks
New Member
Join Date:
Dec 2007
Posts:
218
#6
Feb 15 '08, 02:30 PM
Originally posted by
harshmaul
Hi werks, you can check this link out...
Creating a PHP CMS for administration
Thanks for the link..
--
Kenneth
"Better Than Yesterday"
Comment
Post
Cancel
werks
New Member
Join Date:
Dec 2007
Posts:
218
#7
Feb 15 '08, 02:31 PM
Thank you
ronverdonk
no hard feelings..
--
Kenneth
"Better Than Yesterday"
Comment
Post
Cancel
ronverdonk
Recognized Expert
Specialist
Join Date:
Jul 2006
Posts:
4259
#8
Feb 15 '08, 02:37 PM
See you again.
Ronald
Comment
Post
Cancel
harshmaul
Recognized Expert
Contributor
Join Date:
Jul 2007
Posts:
490
#9
Feb 15 '08, 03:11 PM
No problem, I'm here to help :)
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment