Form action to refresh current tab

Im trying to get my contact form which is in a tab to stop refreshing on submit to the home tab. I thought by adding an anchor link it would sort itself but its still going to the home tab when the form is submitted.

http://stevanbarry.com/#contact is the link

code in question is;
<form class="form-horizontal" role="form" method="post" action="#contact">

The “action” should point to where the form is being processed. At the end of the processing script, usually there is a redirect back to where you want the user to end up after the form is submitted.

Could you please post the code you have which processes the form?

Apologies - on inspection I thought the php was only processing a div see code below;

<?php
    if (isset($_POST["submit"])) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $human = intval($_POST['human']);
        $from = 'Contact Form'; 
        $to = 'info@test.com'; 
        $subject = 'Message from Contact Form';
        
        $body ="From: $name\n E-Mail: $email\n Message:\n $message";

        // Check if name has been entered
        if (!$_POST['name']) {
            $errName = 'Please enter your name';
        }
        
        // Check if email has been entered and is valid
        if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            $errEmail = 'Please enter a valid email address';
        }
        
        //Check if message has been entered
        if (!$_POST['message']) {
            $errMessage = 'Please enter your message';
        }
        //Check if simple anti-bot test is correct
        if ($human !== 5) {
            $errHuman = 'Your anti-spam is incorrect';
        }

    // If there are no errors, send the email
    if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
        if (mail ($to, $subject, $body, $from)) {
            $result='<div class="alert alert-success">Thank You! I will be in touch</div>';
        } else {
            $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later.</div>';
        }
    }
        }
    ?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.