I have an exercise for school that I have to work out. My teacher is letting us figure it out ourselves, but I've ran into some troubles:
- We have to make 2 files: sescook1.php and sescook2.php.
- We have to make a form for the user to fill out their name and favorite color (in sescook1.php).
- We have to check the input (whether there is input or no). If there's isn't any input, we have to echo 'Please fill out __' (in sescook1.php)
- We have to store the name in a session variable and the color in a cookievariable (in sescook1.php)
- If both fields are filled in, we ave to show a link 'go to the next page' (where 'next page' is an URL to sescook2.php).
- All info has to be shown in sescook2.php (Entered name: __, Entered color: ___)
- You have a link 'Go back to previous page' (where 'previous page' is an URL to sescook1.php)
My code:
This is the code I got so far. My problem is that the page refreshes itself after it does the checkContent function. I'm also not sure how I save my name in a session variable and the color in a cookie variable (and pass them to the next page as well!).
We haven't learned anything on cookies and sessions except our own trial and error and things I found on the internet. Unfortunately, I can't really find lots of useful info (most people refer to Ajax, but we can only use php), or I'm looking in the wrong place.
Thanks for your help in advance!