Jump to content


fetching a website

  • Please log in to reply
1 reply to this topic

#1 daughn888

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 July 2006 - 05:59 PM

I need to know a command that will display one of my site's web pages if a certain form value equals a certain value.

For instance, in a form validating program/quiz I am writing, I have the a "wrong answer" prompt displayed on screen if the user gets the wrong answer...

$question1 = $_POST['q1'];

if ($question1 != "results") {
echo "sorry, wrong answer. Please hit your browser's back button and try again. ";

but if the user types in the correct answer, I would like the php script to automatically display in the same window another of my html pages.  What command would I use to automatically pull up another html page?

Any help would be appreciated.


#2 pixy

  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 06:03 PM

Couldn't you just use include("page.php"); or redirect them to page.php with header("location: page.php"); (but remember rules for sending headers so you don't get errors).

Or, use this function for redirecting:
function redirect($path, $timeout=2, $type=X_REDIRECT_HEADER) {

    // split session attack code fix
    if (strpos(urldecode($path), "\n") !== false || strpos(urldecode($path), "\r") !== false)
        error('Tried to redirect to potentially insecure url.');

    // force session to be written before redirecting

    $type = (headers_sent() || $type == X_REDIRECT_JS ) ? X_REDIRECT_JS : X_REDIRECT_HEADER;
    if ($type == X_REDIRECT_JS) {
        <script language="javascript" type="text/javascript">
        function redirect() {
            window.location.replace("<?php echo $path?>");

        setTimeout("redirect();", <?php echo ($timeout*1000)?>);

    } else {
        if ( $timeout == 0) {
            header("Location: $path");
        } else {
            header("Refresh: $timeout; URL=./$path");
    return true;

And then, when you want to redirect do something like:
redirect("page.php", 0);
0 is the time, so adjust it higher if you want it to linger one the results page before redirecting.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users