There are a few problems here. Firstly, you don't have a name attribute for your submit button to match the conditional statement, so that will never happen.
Plus, you're outputting before header with the HTML on top of your PHP.
Then, the extra </form>
tag after <form method="post">
; that needs to be removed.
Therefore, you need to modify your code to read as:
<?php
if ( isset( $_POST['submit'] ) ) {
header("Location: $PaymentPage", false);
exit; // added to stop execution if more code is below it
}
else{
echo "It is not set.";
}
?>
<form method="post">
<div class="col-sm-offset-2 col-sm-4">
<button name="submit" type="submit" class="btn btn-default">Confirm</button>
</div>
</form>
Error reporting would have thrown you an undefined index submit notice.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.
N.B.:
Now, $PaymentPage
is undefined, so I have no idea where you've defined it or what that value should be.
Sidenote: Forms default to "self" when an action to another file isn't defined.
References: