Question:
(html or php) Website programming question?
2011-06-19 06:50:09 UTC
Say there was a button along with a drop down menu on a previous webpage (lets name it: http://tester.com/first.html) that made you redirect to the next page (e.g. http://tester.com/second.html).

But if someone tried to bypass the first page (http://tester.com/first.html) by entering to the next page (http://tester.com/second.html), how would you redirect them back to the first page? Wouldn't a boolean or something similar be used? Can you please share with me codes that will do the mentioned above.

Side question: Also if you can, what are the codes to make a drop down menu function with a redirecting button?
Four answers:
johndehaura
2011-06-19 06:57:12 UTC
.htaccess redirect



If you are using Apache server, then create an empty text file and name it ".htaccess" (without the quotes of course). Open it up in word pad or similar, and use this example (replacing the URL and file name, .htm, .php, etc...):



redirect 301 /oldfile.htm http://www.domain.com/newfile.htm



Save it, and then FTP it to the relevant working directory on the web server.
Astano
2011-06-19 11:14:36 UTC
You could start a session and set a session variable, if the variable is set on the next page then do nothing otherwise redirect to the first page.



pageone.php




session_start();

$_SESSION['redirect'] = false;

// Insert this at the top of the page!

?>





pagetwo.php




session_start();

if(!isset($_SESSION['redirect'])){

header("location:pageone.php");

}

// Insert this at the top of the page!

?>
?
2016-12-22 10:43:51 UTC
i think of any textual content textile editor is nice, ideally one with syntax highlighting. And Wampserver on your webserver and database. forget approximately approximately Dreamweaver and so forth.. you will no longer have the means to apply it in case you're no longer fluent in html 4 / xhtml and css... And as for Hypertext Preprocessor, nicely you certainly ought to code that. regardless of in case you utilize some thing like wordpress.. you nevertheless must be attentive to a thank you to code. I advise discovering step with the aid of step.. start up off setting up Wampserver.. and study a thank you to apply the phpMyAdmin database. study a thank you to create databases, question them and so forth.. then see in case you could create an elementary cyber web-website to demonstrate the contents of a database table applying html 4/css, Hypertext Preprocessor and sq.. yet another straight forward exercising is to enforce an elementary cyber web-website counter. you do no longer desire a database for this.. you will discover straight forward Hypertext Preprocessor scripts on the internet that save the suggestion in a textual content textile document. lower back you are going to desire Wampserver put in.
merlot7799
2011-06-21 14:21:34 UTC
There are a few ways to do this. The variable $_SERVER('HTTP_REFERER') refers to the url of the page that took you to the page you're on. So, in your second page, simply check to make sure that $_SERVER('HTTP_REFERER') equals the address of your first page.



It sounds like you want to pass a variable from page one to page two, using a dropdown. Incidentally, that code would look something like this:













This would create the dropdown box you want, and would pass either value1 or value2 in the variable $_GET['choice'] on page two. You could just check for the existence of that variable, and you can be reasonably sure that page one was used to get to page two....reasonably.



Combine both of these checks to be pretty darned sure.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...