How to redirect to the current page with form in php?

forms, php

Solution

leave the action part empty to redirect to current page eg:

<form action="">

or if you want to redirect to some other page, you can do so like this:

<form action="somepage.php">  // page must be in the same directory

If you want to append query string then:

<form action="somepage.php?var=value&var2=value">

If you want to redirect to a page one directory back then:

<form action="../somepage.php?var=value&var2=value">

Two directories:

<form action="../../somepage.php?var=value&var2=value"> and so on

inside a nother folder

<form action="yourfolder/somepage.php?var=value&var2=value">

Problem

I tried to redirect to the current page with form in my php application. Now i have met a problem. ``` <form name="myform" action="?page=matching" method="GET"> <input id="match_button" type="submit" name="button" value="button" onClick="func_load3()" /> </form> ``` `action="?page=matching"` means the current page, because i use the single entry in my php application. With the code upon, When i click the button, it redirects to the homepage. And I tried to use: ``` <form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> ``` but it still doesn't work. So i have to ask for help from you. Do you have any ideas about that? How to fix it? Thanks in advance.

Original source