Jump to content

INeedAGig

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by INeedAGig

  1. I'll try to clarify one more time exactly what I am trying to do. I appreciate all of your help so far! I'm just a little confused with the cookie portion of it. The user goes to www.example.com in their browser, and they see the homepage (index.php) just like they would any website and since it is the first time they are visiting the website, they do not have access to any other part of the website until they complete the form. Upon completion of the form they are re-directed (via the form processor) to the page where they can now access all of the content on the website, keep in mind, this is not a user system where they will need to log in and out, just a way of getting the user to fill out the form so they can access content. Now, this is where I need the help, the cookie. For example, the same user returns to the site via www.example.com a couple days later and since they already filled out the form at a prior time they are automatically redirected to the content page, which essentially is now the homepage for them. Keep in mind, the form is on the homepage (index.php), if its a first time visitor I want index.php to load just like it always would, if it's a return visitor then I want content.php to load, which is essentially the return visitors homepage. Here is some of the code I have, so you have a reference. This cookie retrieval string is on the index.php page right after the <body> tag <?php if(isset($_COOKIE['user'])) { header ("Location: content.php"); exit(); }else{ header ("Location: index.php"); } ?> This is the first string of code in the form processor to set the cookie (this is working) <?php setcookie("user", "1", time()+3600*30000, "/"); I have been testing and testing, clearing the cookie everytime, moving the spots where I am putting the cookie retrieval code in the index.php, etc. It works to set the cookie the first time, but every visit after that is either a blank page or always loading index.php
  2. I changed the setcookie to what you suggested and now when you go to the form page it is returning blank.
  3. Okay, now it is just loading the index.php page (the form page) no matter what, I did check and the cookie is there. Here is the code I am using on the index page with the form to make sure the cookie is there. This is in between the <html> and <head> tags on the page. <?php if(isset($_COOKIE['user'])) { header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/main.php"); exit(); }else{ header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/index.php"); } ?> Here is the code to set the cookie at the very top of my form processor (this is working, with the exception that it expires when the browser is closed for some reason) <?php $expire=time()+60*60*24*120; setcookie("user", $expire);
  4. Thank you for the replies. I am having a bit of trouble with the retrieval of the cookie. When I place the isset code on the form page, it is just returning a blank white page when I go to it in my browser, any tips?
  5. Thanks for the reply. I need help getting the cookie set as well and the proper place to put the code for it. I haven't really messed with cookies before so it is new to me. Thanks!
  6. First, I would like to say hi to everyone, I just registered, so I am new to the forums! But at any rate, I have a question. I have a form that I have programmed in PHP and upon completion of the form, sends the inputed information to my clients e-mail (acts as a lead) and redirects the user to the main part of the website, where you can access all of the content. Now, I need a little assistance on how to make it so if the same user comes back to the site again, they won't always have to fill out the form and it will just forward them to the main page. Clarification: This is what I'm trying to figure out When you go to the url for the first time, the index page has the form on it that must be filled out before you can access the rest of the pages on the website (I have this set as a redirect in the php processing after you submit the form). What coding would I have to add to the html on the form page (index) and/or my php processor and/or the html on the page you are redirected to? My overall goal is for the user to only see the form page once, after they have submitted it the first time, the next time they visit the url, I want them automatically re-directed to the main part of the site since they already completed the form. For Example: (I have this part programmed and working already) The user goes to http://www.example.com for the first time and they see the page with the form on it. They fill it out and click "Submit" and are re-directed to http://www.example.com/page2.html, this redirect is handled with a header "location" command. (This is the part I need help with) At a future time the same user returns to http://www.example.com and since they have already filled out the form they are automatically re-directed to http://www.example.com/page2.html without having to hit the "Submit" button or really even see the form page. Thank you very much in advance, I appreciate your help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.