Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page change dependent on result from sql

Status
Not open for further replies.

Angua

Programmer
Joined
Sep 10, 2003
Messages
2
Location
DE
Hey,
My PHP isn't great, I need to preform a different task depending on the result of the sql query, I have.....

for( p=0; p<3; p++)
{
<?php

// Request the info
$result = mysql_query(&quot;SELECT psword FROM db WHERE psword='password'&quot;);
if (!$result) {
echo(&quot;<P>Error performing query: &quot; .mysql_error() . &quot;</P>&quot;);
exit();
}
else
if ($result == password ){
<a href=&quot;menu.html&quot;></a>
}
else
if( p=2 ){
echo(&quot;<P>Account not blocked</P>&quot;);
exit();
?>
}

If result from query is the same as the password that was read in I want it to go directly to menu.html, is a link correct here ?

Thanks for any help,
Angua
 

Ok cool, yeah I want them to be redirected automatically so instead of

else
if ($result == password ){
<a href=&quot;menu.html&quot;></a>
}

I should use

else
if ($result == password ){
header(&quot;Location: menu.html&quot;);
}


Yes ?, Angua
thanks for the really quick response by the way





 
precisely...

Known is handfull, Unknown is worldfull
 
Angua:
It may be possible to use the &quot;Location:&quot; header in your code. But it is not guaranteed.

If your script has produced output before you use the header() function, you will get the dreaded &quot;Cannot modify header information - headers already sent by...&quot; error and your script will halt.

You can work around the problem by either insuring that your script does not output any content (including errors or warnings) before it uses the header() function, or through the use of output control functions (more information:
Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top