In my case I have to submit form on same file which is a class without using any javascript or hook, the form action is action="<?php echo $_SERVER['PHP_SELF']; ?>"
. It is submitting the form but redirecting to the main page of the site. If the page link is http://sitename.com/my-link/
and the form is on this link, after submitting form the url should be http://sitename.com/my-link/?taskname=abc
but it is redirecting to the main site page like this http://sitename.com/?taskname=abc
. What I am missing here
class tasks{
function search_form(){
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET" >
<input type='text' name='taskname' >
</form>
}
function search_form_submit(){
echo $_GET['taskname'];
}
}
$tasks_obj = new tasks();
if($_SERVER['REQUEST_METHOD'] == 'GET') {
$tasks_obj->search_form_submit();
}
action=""
attribute will always post to the current URL