-1

I know how to accomplish this in PHP. Is is possible to redirect using only HTML, After form get submitted?

<form action="login.php" method="POST" />
Aqilhex
  • 115
  • 1
  • 2
  • 14
  • Redirect is done with `header("Location: /path/here")` function. – u_mulder May 02 '17 at 20:10
  • At [so] you are expected to try to **write the code yourself**. After **[doing more research](//meta.stackoverflow.com/questions/261592)** if you have a problem you can **post what you've tried** with a **clear explanation of what isn't working** and providing a [**Minimal, Complete, and Verifiable example**](//stackoverflow.com/help/mcve). I suggest reading [ask] a good question and [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). Also, be sure to take the [tour] and read **[this](//meta.stackoverflow.com/questions/347937/)**. – John Conde May 02 '17 at 20:10
  • But not in PHP, in HTML? Why tag the question with PHP, then? – Don't Panic May 02 '17 at 20:15

2 Answers2

2

On submit(you have a submit button named submit) and hopefully named form input's such as <input type='text' name='usernameFromForm' />

fire the header function

if(isset($_POST['submit'])){

    $_POST['usernameFromForm'];
    // Do something with this variable, put into database, etc
    // Redirect
    header('Location: http://www.example.com/');
}
clearshot66
  • 2,292
  • 1
  • 8
  • 17
0

After you preform some tasks with the $_POST data in your login.php page, use the PHP header() function to determine the location to go to. Use header() before any HTML is printed.

Sterling Beason
  • 622
  • 6
  • 12