Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Can someone recommend a customizable contact form, please? Reply To: Can someone recommend a customizable contact form, please?

#169456
__
Participant

No problem.

Should all of the JS come out of the form as the coding you’ve created doesn’t use JS (if I understand correctly.)

Leave it all out, for now. We can add JS later, but for now, there’s none and we don’t want it to get in the way of testing.

I even managed to screw up my original contact form and have spent the biggest part of the day fixing it!

Ah-hah! Don’t work on your original files directly. Make backup copies. When programming, never do anything unless you can get your original script back in just a few clicks.

Please explain again exactly what I need to put in the contact form and what other files need to be created/altered if any.

Create a new file that holds the class definition. (Just copy+paste what we have in the gist.) I recommend naming this file after the classname, e.g., “contactMichael1961.php.”

On your “contact me” page, put whatever HTML+CSS you want for your layout. Then, at the very top, above everything else, include the class definition and create a new object from it:

<?php
include_once "path/to/contactMichael1961.php";
$contactForm = new contactMichael1961;
?>

In your page’s HTML <head>, print the form’s CSS <style> element:

<?= $contactForm->cssStyle(); ?>

In your page’s HTML <body>, print the HTML <form> itself:

<?= $contactForm->htmlMarkup(); ?>

That should give you the initial contact page. Nothing will happen -yet- when you submit it, but I want to make sure things are working “so far.”