PHP: How can I make the form submission confirmation look better?


I’ve posted here since I don’t see any forum related to PHP. I was hoping you guys would help me with making my form submission look better after a user submits. (Not a PHP expert here, but at least I got it to work :joy: )

Right now, the confirmation page is just in plain text, and would like to attach a CSS stylesheet or something similar.

Here is my website with the contact form submission page:

PHP code here:

<?php session_start(); ?>

$honeypot = FALSE;
if (!empty($_REQUEST['a_password']) && (bool) $_REQUEST['a_password'] == TRUE) {
    $honeypot = TRUE;
    # treat as spambot
} else {
    # process as normal

if(isset($_POST['submit'])) {
$from = "";
$to = "";
$subject = "Portfolio Contact Form Submission";
$headers = "From:" . $from;

 		# Sender Data
        $name = str_replace(array("\r","\n"),array(" "," ") , strip_tags(trim($_POST["name"])));
        $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
        $message = trim($_POST["message"]);
        if ( empty($name) OR !filter_var($email, FILTER_VALIDATE_EMAIL) OR empty($message) ) {
            # Set a 400 (bad request) response code and exit.
            echo '<p class="alert alert-warning">Please complete the form and try again.</p>';

            # Mail Content
            $content = "Name: $name\r\n";
            $content .= "Email: $email\n\n";
            $content .= "Message: $message\n\n";

            $success = mail($to,$subject,$content,$headers);

            # When sending the email.
            if ($success) {
                # Set a 200 (okay) response code.
                echo '<p class="alert alert-success">Thank You! Your message has been sent.</p>';
            } else {
                # Set a 500 (internal server error) response code.
                echo '<p class="alert alert-warning">Oops! Something went wrong, we couldnt send your message.</p>';
            //redirect to home


    } else {
        # Not a POST request, set a 403 (forbidden) response code.
        echo '<p class="alert alert-warning">There was a problem with your submission, please try again.</p>';


Thanks a million!

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