Search code examples
phphttp-redirectrefreshreload

PHP: Redirect same page after click the submit button


Is there a way to redirects to the same page using PHP.??? I just need to reload or refresh the gridview. I don't need to redirect to a website or link, I need is redirect it to the same page or same form like main.php.

I already used the header(), but its not working to me and all I see is linking in the website.

Thanks.


Solution

  • Here are two example to redirect to a form. Lets say that your filename is main.php

    <form action="main.php">
    Name: <input type="text" name="name">
    <input type="submit" name="submit" value="Submit">
    </form> 
    

    Or you can use this

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
    Name: <input type="text" name="name">
    <input type="submit" name="submit" value="Submit">
    </form> 
    

    Did that answer your question?