Downpour Posted September 8, 2008 Share Posted September 8, 2008 I am trying to make a download page only accessible after the person fills out a form. I was told that the best way to do this was with sessions variables, but I have no ideal how to go about it. Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 Have you reviewed session tutorials? Also, you can also do it by checking if the form was submitted as well and you won't need a session. Quote Link to comment Share on other sites More sharing options...
james g Posted September 8, 2008 Share Posted September 8, 2008 Something like this would go before the form: session_start(); $_Session['formread'] = 0; Then, after the from has been submitted, change the session variable, like: $_Session['formread'] = 1; Then, you can have an if statement to do display the download page IF the user has submitted the form. if ($_Session['formread'] = 1) { //display download page Or redirect header to download page } Does this help? Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 Thank you!! Will the people still be able to connect to my download page directly? I want them to go through the form first before they can get to the download page. Some people may just copy the url and skip the form all together!! Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 Not if you check either submit or the session first. Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 I'm sorry I'm a real newbie at this. I've never worked with sessions before!! How do I check if submit was entered? Right now I have formail, so when they click submit and enter the information it brings them to my download page. But if I place the page directly in the url, I can go straight to the page. Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 Post your code for your form. Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 <form method="post" action="phorme.php" name="SampleForm"> <input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER"> <input type="hidden" name="recipients" value="myemail" /> <input type="hidden" name="required" value="email:Your email address,realname:Your name" /> <input type="hidden" name="subject" value="Subcription" /> <input type="hidden" name="good_url" value="http://mywebsite/download.html" /> <input name="realname" type="text" size="12" ></p> <input name="email" type="text" size="12"></p> <input name="Submit" type="image" src="index_files/Squeeze2_27.jpg" border="0" alt="" width="148" height="40" value="Submit"/></td> </form> Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 On your download page, you can add this to the top. Change the yourform.php to your actual form page or where you want them to go if they try to go directly to it. <?php if(!isset($_POST['Submit'])) { Header ("Location: yourform.php"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 Ok, I placed it above < html > at the top of my download page. But I can still access the page!! I cleared my cookies and cleaned the cache, just to make sure. Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 Did you close the browser? Post the code how you have it now. Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 No I didn't close my browser! Should I have? this is how I have it: <?php if(!isset($_POST['Submit'])) { Header ("Location: index.php"); exit; } ?> <html> <head> <title>Inside the Minds of Winners -- Successful People Really Are Luckier!</title> <meta name="MSSmartTagsPreventParsing" content="TRUE"> </head> Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 And that is phorme.php right? Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 No that is on my download page. download.html Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 A html page can't parse PHP (well not without telling your webserver to). Your form points to phorme.php after it's processed. So what does that page do? Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 8, 2008 Author Share Posted September 8, 2008 A html page can't parse PHP (well not without telling your webserver to). Your form points to phorme.php after it's processed. So what does that page do? The phorme.php is the formail.php It sends the info of the form to me in an e-mail! I also tried putting phorme.php in the location but it didn't work either!! Quote Link to comment Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 So how do you get to the download page? Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 9, 2008 Author Share Posted September 9, 2008 When you hit submit the page goes here, it's in my form code <input type="hidden" name="good_url" value="mywebsite/download.html" /> Quote Link to comment Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 When you hit Submit, it goes to your action page <form method="post" action="phorme.php" name="SampleForm"> Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 9, 2008 Author Share Posted September 9, 2008 Yes, but then it gets redirected to my download page. Quote Link to comment Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 You'll need to set a session then on your form page, change your download page to a .php page instead of .html, add the session check on that page. What is the purpose of phorme.php if all it does is redirect away? Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 9, 2008 Author Share Posted September 9, 2008 No it sends me an e-mail with the data on my form. Then re-directs the visitor to the download page after they submit it. So if I change my download page to .php and then how do I go putting a session in it. That's what I don't understand!! Quote Link to comment Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 Post the phorme.php code. Quote Link to comment Share on other sites More sharing options...
Downpour Posted September 9, 2008 Author Share Posted September 9, 2008 I'll attach it, because it is very long. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 Rename download.html to download.php Change <input type="hidden" name="good_url" value="mywebsite/download.html" /> to <input type="hidden" name="good_url" value="mywebsite/download.php" /> Add the code from page 1 to your download.php page (if you didn't already). If that doesn't work, you'll have to incorporate sessions. Quote Link to comment 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.