Forum Moderators: coopster

Message Too Old, No Replies

User authentication redirect

         

petenyce106

2:28 pm on Feb 19, 2004 (gmt 0)

10+ Year Member



im trying to redirect a user after there passwords match. i have this code im using and another forum helped me but im getting a parse error i hope you guys can help thanks pete

<html>

<head>
<title>Member Look up</title>

</head>

<body bgcolor="006666">
<?php
if ($_POST['Facid']!= "") $Facid = $_POST['Facid'];
if ($Facid!= "") {
@ $db = mysql_pconnect('localhost', 'eni', 'password');

if (!$db) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
} else {
$listing_query = "select * from ehpadmin.Facility where Facid = '".$Facid."'";
$listing_result = mysql_query($listing_query) or die("Error in return query<br>".mysql_error());
$row = mysql_fetch_array($listing_result);
$id = $row["MemID"];

if ($id == "1") {
facility3.html;
}

if ($id == "2") {
facility2.html;
}
$num_rows = mysql_num_rows($listing_result);
if ($num_rows == 0) {
echo '<font color="white"><b>Please try again</b></font></br></br>';
print "Practice ID invalid.</br></br>";
echo '<a href ="poup.html"><font color="white">Back</font></a>';

} else {
<form method="POST">
<p align="left"><b><font color="#FFFFFF">Enter Practice Id</font></b></p>
<p align="left">
<input type="text" name="Facid" size="20">
<input type="submit" value="Go">
</p>
</form>
}
}
</body>
</html>
?>

where it says $id is the new part of the code
any help would be great

andrewB

2:42 pm on Feb 19, 2004 (gmt 0)

10+ Year Member



if ($id == "1") {
facility3.html;
}

if you trying to redirect to facility3.html you should write
something like
header("Location: [".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."...]

facility3.html alone is not a php command so of course it doesn't know what to do.

You need more help you should look at the header() function in the PHP manual or search for "redirect" in the manual

stargeek

6:21 pm on Feb 21, 2004 (gmt 0)

10+ Year Member



I've used a javascript redirect with success in situtaions similar to this:

if ($id == "1") {
echo "<Script>top.location.href='facility3.html'</script>";
exit;
}

someguy

2:24 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



I would suggest perhaps using an include

ie:

if($is_user){
echo "Welcome ".$_SESSION['username'];
include("members.php");
}else{
echo "Please login ya scally wag";
}

theriddla1019

3:31 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



I notice you are closing your php after the </html>, this could be causing you a problem. After each element of a php is completed and html is started close the php. Im not sure of the range but you can use a loop through html like:

<? while ($i < $Num)
{
$Foo=mysql_result($Result,$i, 'Bar');
++i;
?>
<span id=FooBar><?= $Foo?></span>
<? if ($i < $Num) {
$Foo=mysql_result($Result,$i, 'Bar');
++i;
}
?>
<span id=FooBar><?= $Foo?></span>
<?
}
?>

Dunno if thats what your looking for but its a try :)