Forms Show HTML doctype code after submission

I want to know how to remove this message once a submission is made in my form. I see the submission is successful in my forms tab I just don’t know how to remove this code.

Hi @savvYazzy :wave:t6: ! Welcome back to the forums! We’re glad you’re here. :netliconfetti:

This seems to be a problem in your site, not our service. Can you debug your code? I recommend you start with our very thorough forms debugging guide.

If that still doesn’t help you resolve it, can you follow the instructions at the bottom of our support guide. Once you escalate to us showing your work in checking all of the things the article ask we can be of further assistance. Happy building! :rocket:

Hi I went through the debugging link and still can’t seem to figure out the issue

this is my code for my forum, please tell me if you see something because I really don’t know. Can you also tell me how to use the notify thank you page if this doesn’t work. I really prefer it to work though

Submit Message

 <div class="contact-form-box">
                                    <form id="contact-form" class="default-form contact-form" action="mail.php" method="post" data-netlify="true">
                                        <div class="row mb-n6">
                                            <div class="col-xl-6 mb-6">
                                                <div class="default-form-group">
                                                    <input name="name" type="text" placeholder="Name" required>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 mb-6">
                                                <div class="default-form-group">
                                                    <input name="email" type="email" placeholder="Email" required>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 mb-6">
                                                <div class="default-form-group">
                                                    <input name="phone" type="tel" placeholder="Phone" required>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 mb-6">
                                                <div class="default-form-group">
                                                    <input name="subject" type="text" placeholder="Subject" required>
                                                </div>
                                            </div>
                                            <div class="col-xl-12 mb-6">
                                                <div class="default-form-group">
                                                    <textarea name="message" placeholder="Comment" required></textarea>
                                                </div>
                                            </div>
                                            <div class="col-12 mb-6">
                                                <div class="default-form-group tex-center">
                                                    <button type="submit" class="btn btn-lg btn-outline-one">Submit Message</button>
                                                </div>
                                            </div>
                                            <p class="form-messege"></p>
                                        </div>
                                    </form>
                                </div>```

Note sure why you’re setting an action to a php file.

Also, your form seems to have a JavaScript event listener. Try removing that as that seems to be causing this unexpected behaviour.

okay what do I put instead of mail.php. because that file connects the form to my email…

<?php

//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Sending Email from Local Web Server using PHPMailer			
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/Exception.php';


//Create a new PHPMailer instance
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';

$isSmtp = true;
if ($isSmtp) {
    require 'phpmailer/src/SMTP.php';

    //Tell PHPMailer to use SMTP
    $mail->isSMTP();

    //Enable SMTP debugging
    $mail->SMTPDebug = 0;
    //Ask for HTML-friendly debug output
    $mail->Debugoutput = 'html';

    //Set the hostname of the mail server
    $mail->Host = 'mtar.uwo.ca';
    //Set the SMTP port number - likely to be 25, 465 or 587
    $mail->Port = 587;
    //Whether to use SMTP authentication
    $mail->SMTPAuth = true;
    //Username to use for SMTP authentication
    $mail->Username = 'npa@uwo.ca';
    //Password to use for SMTP authentication
    $mail->Password = 'npapassword;';
}

// Form Fields Value Variables
$name = filter_var($_POST['name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$subject = filter_var($_POST['subject'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$message = filter_var($_POST['message'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$message = nl2br($message);

//From email address and name (Change here)
$mail->From = $email;
$mail->FromName = $name;

//Set who the message is to be sent to
$mail->addAddress('ysalim@uwo.ca');

//Set an alternative reply-to address
$mail->addReplyTo($email, $name);

//Send HTML or Plain Text email
$mail->isHTML(true);

// Message Body
$body_message = "Name: " . $name . "<br>";
$body_message .= "Email: " . $email . "<br><br>";
$body_message .= "Phone: " . $phone . "<br><br>";
$body_message .= "Subject: " . $subject . "<br><br>";
$body_message .= "Sessage: " . $message . "<br><br>";
$body_message .= "\n\n" . $message;

//Set the subject & Body Text
$mail->Subject = "New Message from $name";
$mail->Body = $body_message;

//send the message, check for errors
if (!$mail->send()) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message sent!';
}

what do I put as the action if I want to use the standard netfily thank you page. I don’t see it in your docs

I don’t think it does. Netlify doesn’t even run PHP. You’re using Netlify Forms which has nothing to do with your PHP code.

In any case, I’ve mentioned the actual problem here. You need to remove the JavaScript handling your form submission.

why exactly what my other topic closed? This one is asking about a custom message while the other was asking about the generic thank you. I asked about the generic page but I got no response on this form so I started a new topic so its less confusing. By blank I meant nothing happens when a form is submitted.

@savvYazzy The JavaScript handling of your form submission that @hrishikesh is referring to can be seen in this file:
https://www.yasminesalim.com/assets/js/plugins/ajax-mail.js

It is capturing the submission and is what is causing your form to “go blank” as per:

.done(function (response) {
  formMessages.removeClass('error text-danger').addClass('success text-success mt-3').text(response);
  // Clear the form.
  form.reset()
})

so I took it all out

                                    <form id="contact-form" class="" method="post" data-netlify="true">

but now I have a 404 page not found when the form is submitted

@savvYazzy I’m not sure what you mean by “I took it all out”.

If I check the site at your domain I see…

What you have removed is the data-netlify="true" attribute, which is required as per the documentation.

I can also see that the ajax mail code is still being loaded…

If your goal is to get the Netlify form handling working, then you need to configure the form appropriately with the data-netlify="true" attribute and you should remove (or otherwise change) the ajax form handling in ajax-mail.js so that it either no longer takes effect, or performs correctly to your requirements (see: Forms setup | Netlify Docs).