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

Hi,

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:
michelleshean.com/contact.html

PHP code here:

<?php session_start(); ?>
<?php

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

if(isset($_POST['submit'])) {
$from = "michelleshean.com";
$to = "shean.michelle@gmail.com";
$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.
            http_response_code(400);
            echo '<p class="alert alert-warning">Please complete the form and try again.</p>';
            exit;
        }


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


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

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

        

    } else {
        # Not a POST request, set a 403 (forbidden) response code.
        http_response_code(403);
        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.