• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

PHP Website

G

gmagnuson

Guest
#1
Would anyone have a php website that has a login area that I could look at the coding for. I am trying to learn php and I learn best by looking off of a template. It can be an older php website doesn't matter. Thanks!
 
#4
Here's the code I use (you will need a database for the user info):

This handles the login:
PHP:
	function Validate(){
		global $name;
		global $password;
		global $db;
		$users = "SELECT * FROM users WHERE nick='$name'";
		$getval = mysql($db,$users);
		if (mysql_numrows($getval) != 0){
			if (mysql_result($getval, 0, 'password') == $password){
				return true;
			}
			else return false;
		}
		else return false;
	}

	if(Validate()){
		session_start();
		session_register("pass_cookie");
		$pass_cookie = $name;
		header("Location: logged_in.php");
	}
	else{
		// Authentication failed.
		header("Location: login.php?badpass=yes");
	}
This is the first page:
PHP:
<FORM NAME="login" METHOD="post" ACTION="login_check.php" TARGET="main">
Name: <INPUT TYPE="text" NAME="name"><BR>
Password <INPUT TYPE="PASSWORD" NAME="password"><BR>
<INPUT TYPE="Submit" VALUE="Log in" BORDER="0">
</FORM>
 

w0lv3rin3

The Source
Political User
#5
well if your new with php i suggest u get to know some of SQL ODBC DB

PHP is a DB language, just pulls out info from those DB.
 

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,014
Latest member
sanoravies