Login form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fuyenhou
Forum Newbie
Posts: 9
Joined: Tue Jun 22, 2004 4:54 am
Location: Malaysia
Contact:

Login form

Post by fuyenhou »

8) This is the first time I am developing things with pHP... and Mysql.
I have some question while developing web site of my own


This is the coding of my process.php
When user log in with the correct name and password and initial = 1 I do expect them to enter success1.htm else I will rather them into success0.htm.

If the user doesnot enter the correct name and password I will want them to enter error.htm

<?
$conn = mysql_connect("localhost","fuyenhou_freetohost_com","94247");
$db = mysql_select_db("fuyenhou_freetohost_com");

$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from login WHERE username='$username'and password='$password'")
or die ( what can I do here? in order to link to others pages error.htm

$worked = mysql_fetch_array($result);

$username = $worked[username];
$password = $worked[password];
$initial = $worked[initial];


if($worked)
what can I do here? in order to link to others pages<br>
if initial = 0 then log into success0.htm
else if initial=1 then log into success1.htm

?>

anywya do there any if .. end if at the end of the statement? [/b]
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

If think the code you need is:

Code: Select all

<?php
header ("location: pagename.php");
?>
Change pagename.php to be whatever you want.

A word of warning - the header command will fail if you have sent anything to the browser to be displayed, so make sure that code goes at the top of your page, before your <html> tag.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Could just include() it too.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you can use your $worked['username']; n password in an if statement and compare them them the $_POST vars. I would check it that way, it just seems more secure.

you can use JS to forward users to other pages too

<script language=javascript>location.replace('page.php');

or if u wish to use headers, thats fine too.
Post Reply