PHP Contact Form Validation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • losingpatience
    Private

    • Sep 2007
    • 2

    PHP Contact Form Validation

    Hi there!

    I'm developing my website with BlueVoda, and I added a "contact form" with a Thankyou.php page:





    So, my contact form & Thankyou page work perfectly, I receive the feedback from my visitors... the problem (there's always one, huh?) is that I need to "validate" the form, that is to say, to have a little piece of code able to check the three fields (name, email, comments) before sending me an empty email, to prevent what now happens: email account collapsed with empty emails...

    I've tried to validate it through javascript, in the same page of the form, "contact.html", but it doesn't work... as soon as I click to send the form (through Thankyou.php, as action="Thankyou.php" and method="post"), the thankyou page processes an empty email to my account...

    And I know nothing about php scripting, so I should not "touch" any code provided by BlueVoda & Forum Members working as is...

    Can anyone help me, please...? I just need to stop empty emails collapsing my account with the same structure I have now (no more pages):

    + Contact.html (contains the basic form and sends it to process it through Thankyou.php)
    + Thankyou.php (contains the php code provided below and a Thank You message)

    <?PHP
    $email = $HTTP_POST_VARS[email];
    $mailto = "myemail@mydomain.com";
    $mailsubj = "Envío de Formulario de Contacto";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "Valores enviados desde el formulario de contacto :\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    ?>

    Thank you in advance and, please, forgive my english, I'm not an english native speaker!
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: PHP Contact Form Validation

    There are two ways to validate fields:

    1. Through javascript. However, you don't need to embedd external Javascripts. In your BV form, double click the fields, and select Validate. It will give you some options for validation, among them Required field, Custom error message , email address, etc.

    2. Using ABVFP. It will perform php validation which cannot be overidden by users that have disabled Javascript in their browsers, and also has a lot of other features. Have a look at Advanced BlueVoda Form Processor
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • losingpatience
      Private

      • Sep 2007
      • 2

      #3
      Re: PHP Contact Form Validation

      First of all, I apologize for asking questions that could be answered just paying attention to a well done job... I mean the BlueVoda website builder, with its validating forms options...

      Thank you, navaldesign,the first way (javascript in BV) was the (my) solution... The ABVFP is an option too "difficult" to my knowledges...

      Thanks again!!

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: PHP Contact Form Validation

        Not a problem. You have just lost your patience for a moment LOL!!
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment

        Working...
        X