Skip to main content
Topic: Error 403 on submitting a form (Read 1332 times) previous topic - next topic

Error 403 on submitting a form

I'm customizing the "info/contact.php" file.
I want replace the the sample contact form, with my own contact form.

When the user clicks on the submit button, an email should be sent with the form details.
This is the form code:

Code: [Select]
<div class="info-form">
        <form action="" method="post">

            <div class="name">
                <label>Enter your name..</label><br>
                <input type="text" name="name" required>
               
            </div>
           
            <div class="email">
                <label>Enter your email..</label><br>
                <input type="email" id="email" name="email"required>
               
            </div>
           
            <div class="yourmessage">
                <label>Briefly describe your topic</label><br>
                <input type="text" name="ymessage" required>
               
            </div>
           
            <input type="submit" name="submit" value="Submit">
            </form>
    </div>


And, on the same page, I have inserted a Php script that sends the email, using the mail function:

Code: [Select]
<?php
        if (!empty($_POST["email"])) {
            $to = "myemail@gmail.com"; 
            $subject = 'contact form';
            $from = "admin@theilmtech.com";
            $fromName = "Junaid Khan";
            unset($headers);
            $headers = "From: $fromName"." <".$from.">";
            $msg = "Mail: ".$_POST["email"];
            //Need to modify Header
            $mail = @mail($to, $subject, $msg, $headers);
            header("Location: info/contact.php");
        }
    ?>

When I click on the submit button, I get a 403 Forbidden error.

What can I do to solve this ?

Re: Error 403 on submitting a form

Reply #1
@junaid97‍ create a contact table and exempt the add page from authentication. And now point your contact form action to the contact table add page you created, then on Action after add or Action before add, you can add your email code there. On the left panel, you should see SendMail as part of the list of the code snippets, double click on it and you will get a sample email code.