Posted by Jonathan on 10/02/37 11:35
vncntj@hotmail.com wrote:
> if ($HTTP_POST_VARS["postback"]=="y") {
> // Printing results in HTML
>
> echo "<table>\n";
> echo "\t<tr>\n";
> echo "\t</tr>\n";
>
> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> echo "\t<tr>\n";
> foreach ($line as $col_value) {
> echo "\t\t<td>$col_value</td>\n";
> }
> echo "\t</tr>\n";
> }
> echo "</table>\n";
> }
>
> // This is where I'm having difficulty....
>
> if ($col_value) == "1" {
> header("www.espn.com"); /* Redirect browser */
>
> /* Make sure that code below does not get executed when we redirect. */
> exit;
> }
I think the problem might be that you use the header() function
incorrect. If you would like to redirect the user to the english version
of the header() function description you should do that like this:
header ("Location: http://www.php.net/manual/en/function.header.php");
The second problem could be that you try to access the $col_value
outside the foreach loop... it might be that there is really no value or
there is no value anymore...
You might want to change your code like this:
if ($HTTP_POST_VARS["postback"]=="y") {
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
if ($col_value) == "1" {
header("Location: www.espn.com"); /* Redirect browser */
echo "\t\t<td>$col_value</td>\n";
} else {
echo "\t</tr>\n";
}
}
echo "</table>\n";
}
exit;
}
Some other tips... don;t hardcode your passwords in your files, use
include files (preferrably in a subdirectory) which you can only allow
access to by the webserver/php user. This way your username and password
are saver from the outside world.
Jonathan
Navigation:
[Reply to this message]
|