Button type ="submit" also redirects to another page after submitting?

button types clothing
mdn button types
input type=button
html button with link
button type=submit'' onclick
button html
button css
button onclick

How can I make my button ""input type="submit" value="Create" class="btn btn-default" " also redirect to another page(View) after submitting? Basically, I made a simple Form which sends email after that button click, and automatically returns me to Index page (default controller option(asp.net mvc core)), and i want to redirect it to another "Thank you for submitting an email" page(View).


You forgot to add action='index.php' to your form tag.

e.g.

<form action='index.php'>
<input type='submit'/>
</form>

Button Type In HTML: Here's Why You Should Always Declare It », Button Types. There are three types of buttons: submit — Submits the current form data. (This is default.)  Two button elements that act as one submit button and one reset button (in a form): <form action="/action_page.php" method="get"> <label for="fname">First name:</label>


// in PHP you can use

redirect('thank-you.php'); 
or 
header('location:thank-you.php');

/* function for redirect index or home page after some time you can write a setTimeout function in thank-you page.*/

<script>
  $(function(){
   setTimeout(function(){ window.location.href = "index.php"; }, 3000);
});
</script>

// I hope this is work for you.

<button>: The Button element, https://developer.mozilla.org › › <input>: The Input (Form Input) element Therefore, it is a good practice to always declare the type of a button explicitly. Difference between <button type="submit"> and <input type="submit"> Both <button type="submit"> and <input type="submit"> display as buttons and cause the form data to be submitted to the server.


use action attribute inside form element that will redirect you to the page where you want it to be,

just you need to give the link or directory of that file or page or if you have created routing, then give route path according to the framework you are using this will help you for clear understanding

<form action="another_page.php"> <input type="text"> <button type="submit"> </form>

<input type="button">, input elements of type button are rendered as simple push buttons, which can be programmed to control custom functionality anywhere on a  <input> elements of type button are rendered as simple push buttons, which can be programmed to control custom functionality anywhere on a webpage as required when assigned an event handler function (typically for the click event). The source for this interactive example is stored in a GitHub repository.


you could use a return RedirectToPage("Thankyou"); as the return statement of your controller Action so that it redirects to a Thankyou.cshtml page.

button (type=button) element, The button element, having the "button" value in its type attribute, instructs the browser to provide a regular button which has no associated action. The label of a  HTML <input type="button">. ❮ HTML <input> type attribute. A push button that activates a JavaScript when it is clicked: <input type="button" value="Click me" onclick="msg()">.


button (type=menu) element, The button element, having the "menu" value in its type attribute, creates a menu button that when used in a specific combination with other elements ( menu , li  Metal buttons are a very common type of button, and you can find all types of metals when purchasing them. Metal buttons are usually made of materials such as tin and stainless steel, and they can be smooth, textured, hammered, ridged, or even imprinted with various designs.


What's the point of <button type="button">?, Yep, there's a reason - but (usually) only if you're in a <form> element. If you include a button in a form element without specifying it's just a  Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to “image”, but the BUTTON element type allows content.


HTML <button> type Attribute, The type attribute of the element is used to set type of the button. Following is the syntax − Above, we have shown If the button is a submit button (it's inside/associated with a <form> and doesn't have type="button"), specifies how to encode the form data that is submitted.