I have a page with 2 order forms - one for private ant the other for business. I need that when a person submits my form he would see a message on a page or an alert without redirecting to any other php files - everything should take place in the same file. My php file now looks something like this(it's a demo) and it doesn't work I just know that there are no php syntax errors(the problem should be with my code logic):
<?php
header('Content-type:text/html; charset=utf-8');
if ($_POST['private-submit'] == 1) {
if(isset($_POST['private'])) {
/// Php mail code content
@mail($email_to, $email_subject, $email_message, $headers);
$feedback = 'You have been registered!';}
}
if ($_POST['business-submit'] == 2) {
if(isset($_POST['business'])) {
/// Php mail code content
@mail($email_to, $email_subject, $email_message, $headers);
$feedback = 'You have been registered!';}
}
?>
<form id="a" name="private" method="post" action="?">
<ul>
<li> <input type="text" name="private" placeholder="private*" required></li>
<button name="private-submit" type="submit" class="submit" value="1">Order</button>
</li>
<p id="feedback"><?php echo $feedback; ?></p>
</ul>
</form>
<form id="b" name="business" method="post" action="?">
<ul>
<li> <input type="text" name="business" placeholder="business" required></li>
<button name="business-submit" type="submit" value="2">Order</button>
</li>
<p id="feedback"><?php echo $feedback; ?></p>
</ul>
</form>