+ 2
Website Redirection Problem. Any Idea???
Hello Coders I need little help. I want to make a webpage load only when it is redirected from my index page.. I tried to do this but facing problem.. it sometimes redirectes successfully and sometimes causes internal server error.. please provide code in PHP ... For Your Understanding :- I have a webpage ( P1.php ). And a ( index.php ) page. i want to make P1.php only load in browser when it is redirected from index.php . Thanks...
8 Respuestas
+ 4
@Aditya have you tried session? the idea is to start the session in index.php, and store a session variable that indicates that index.php has been visited, then in signup.php you can check whether or not the said session variable is created, redirect to index.php if it isn't.
Or you can define a variable in your link (inside index.php) to signup.php
(e.g. "http://aditya.com/signup.php?from=home")
And then in signup.php check the $_GET for that variable
if(isset($_GET["from"]))
{
if($_GET["from"] == "home")
// We got here from index.php...
}
I never actually implement the second option actually, because user can remember that URL and type it in anyway, so maybe my recommendation is the use of session variable.
Hth, cmiiw
+ 3
@Vinay.s That's not the correct solution i am looking for.. i don't want to include p1.php content on index.php .. i want to make user visit my index.php and only from there he can visit p1.php..
for example ===>
Imagine I have a website named "www.aditya.com" and i allow user to register my website at "www.aditya.com/signup.php" . But I don't want any user to directly visit Signup page by visiting "www.aditya.com/signup.php" in browser... user can only access signup page if he/she is redirected from index.php ...
+ 3
Ipang can you please send me code of session variables and also tell me how to do that. I don't have appropriate knowledge on session variables and it implementation... I mainly do front end development. Thanks in advance
+ 3
@Aditya, you can find it in PHP Tutorial → Predefined Variables → $_SESSION, it covers the basics for session variable, just look in that chapter, I see you have finished PHP course, it's not difficult, I'm pretty sure you'll make it :)
+ 3
Thanks
+ 2
@Aditya, you're welcome, and good luck 8)
+ 1
Hi
<?php
include('p1.php')
?>
please save this code AS index.php. it show what data inside p1.php file on index.php file.
I hope my answer is work anything else replay@Vinay.s
+ 1
I give solutions as soon anything else replayme@Vinay.s