daughn888 Posted July 15, 2006 Share Posted July 15, 2006 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.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14691-fetching-a-website/ Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 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:<?phpDEFINE("X_REDIRECT_HEADER", 1);DEFINE("X_REDIRECT_JS", 2);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 session_write_close(); $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)?>); </script> <?php } 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. Quote Link to comment https://forums.phpfreaks.com/topic/14691-fetching-a-website/#findComment-58597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.