Hi, this is my code. I have created a form in the section “form_page”, but everytime I submit it sends me back to the main page with this URL: http://localhost/seminarka/index.php?send_form=Odeslat
I’ve been trying to figure it out, but I don’t know where I am making the mistake, could someone help me? Thanks.
you don’t specify anything for the action parameter, so it will reload the page you are on when you submit the form. If you want it to load a different page on submit, add that page URL into the parameter.
If that code you posted is called index.php, then it will send you to the same place. The only difference is that it’s now set a variable called $_GET['section'] with a value of “form_page”.
Back to the question by @benanamen, what are you actually trying to do here? And is the code you posted index.php, or something else?
If you want to actually stay on the same page without a refresh, you’ll need to use something like Ajax to submit the form. Using the standard submit it would re-load the page with the various form variables set. I would look at using $_POST instead of $_GET and $_REQUEST, and pass your “section” as a hidden form variable instead of as part of the URL.
Keep in mind that your logic re-draws the form if that variable is set, so if you want to come back to the same page but not draw the form, you need to swap that around.
Yes. But you want to include those files into the index page as needed. A single point of entry is a good setup to have. Make sure to include them dynamically, not with a bunch of if else clauses