Forums

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

Home Forums Back End Contact Form Required Field?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25956
    slacey
    Member

    I’m using the Nice & Simple Contact form and it works perfectly but I need some help with something else.

    How do I make an entry field required to be filled out before submission? You know, where the user gets an error message saying, "Please fill out your name & email."

    The PHP is exactly what Chris gave us other than edits to the To and From emails. If anyone could help, I’d greatly appreciate it!! I’m only familiar with editing PHP and not creating it.

    #63069
    Rob MacKay
    Participant

    I would do – personally and if statement.

    Code:
    if($requiredfield) {

    //it is true – form submitted

    } else {

    //it is false form re-displayed with a message at the top like “fill it in properly” :)

    }

    If you know PHP a little, that will make sense, if not then you might need to give us some code lol

    #63070
    slacey
    Member

    Thanks Rob!

    Well, I guess I don’t know as much as I thought I did because I’m a little confused.

    Here’s my PHP

    Code:
    “;
    exit;
    }

    // prepare email body text
    $Body = “”;
    $Body .= “Name: “;
    $Body .= $Name;
    $Body .= “n”;
    $Body .= “Email: “;
    $Body .= $Email;
    $Body .= “n”;
    $Body .= “Message: “;
    $Body .= $Message;
    $Body .= “n”;

    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);

    // redirect to success page
    if ($success){
    print ““;
    }
    else{
    print ““;
    }

    ?>

    And here is the form in my HTML

    Code:

    We would love to hear your thoughts or comments.
    Please feel free to send a message below.








    #63117
    slacey
    Member

    Yeah I’d love to see it. I don’t really care how it’s done as long as it works.

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