Page 1 of 1

Login form

Posted: Tue Jun 22, 2004 4:54 am
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]

Posted: Tue Jun 22, 2004 7:53 am
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.

Posted: Tue Jun 22, 2004 10:03 am
by Buddha443556
Could just include() it too.

Posted: Tue Jun 22, 2004 6:34 pm
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.