If you are wondering about, How to link submit button to another page using PHP. Then you have come to the Right Place.
Because In this Tutorial, we are going to Link Submit button to another page using PHP.
First of all, PHP is a Server Side Scripting Language. So we can't run Button Clicks Events using PHP but we can use HTML Anchor, Form or JavaScript inside PHP to Link One page with Another Page.
In HTML's Form tag we can Link submit Button to another page using HTML Form's Action Attribute.
Where we have to Write our File Path inside HTML form's action=”” attribute.
After that when the user clicks the Form Button, It will redirect that user to another page.
page1.php
<?php
echo '<form method="POST" action="page2.php">
<input type="submit"/>
</form>';
?>
Results
We can use Anchor <a> tags to Link a Submit button to another page in PHP. We need to Write/Declare Submit button between Anchor <a>...</a> tag's Starting and Closing tags.
By using Anchor tag's href="" attribute we can give a Path where we want to Link our Submit Button.
If you don't want to use Form tag or Ancher tags to Link Submit button to another page in PHP then we can use JavaScript for that.
In JavaScript, we create a Function which will handle all the Data like Page Path where we want to Link our Submit Button.
The function name, By using that Function name we can call that function through HTML onClick attribute. Which we call the assigned
function and we can redirect our users from one page to another by clicking on the Submit Button.