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

Home Forums Back End Help me write this code please

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #37579

    I have been trying for days to get this contact form working on my site. I have rewritten it several times and tried many different things over the days. I just now tried putting it into a class structure. I am a beginner at best with php

    class form
    function validationFalse(){
    echo '
    There was a problem. Please check your form and try again.
    return false;

    function startForm(){
    //get the wordpress database information
    global $data;
    //if the submit button is pressed on the form
    $contactName = strip_tags($_POST);
    if( preg_match('/^[a-zA-Z ]+$/', $contactName) == 'false') {
    //if the contact name doesn't validate, call the error function
    $surname = strip_tags($_POST);
    $email = $_POST;
    $city = strip_tags($_POST);
    $messages = strip_tags($_POST);
    //check to see if the variables are empty, if they are, just exit

    $contact = "Contact Name: $contactName n";
    $contact .= "Surname: $surname n";
    $contact .= "Email: $email n";
    $contact .= "City: $city n";
    $contact .= "Message: $messages n";

    $validation = false;
    echo "You did not fill out the form";
    echo $contactName . $email . $city . $messages;

    $subject = $data;
    $headers = 'From: ' . $data . "rn" .
    'Reply-To: ' . get_bloginfo('admin_email') . "rn" .
    'X-Mailer: PHP/' . phpversion();

    $recipient = $data;

    if(mail($recipient, $subject, $contact, $headers)){
    echo '
    Your message was sent

    $form = new form;

    It might look a little chopped up. Can you help me clean it up and get it working?

    right now, it runs all functions when I press the submit button. Still calls the error message, and still sends the form and gives the success message

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.