Form validation to mail.php

Discussion in 'PHP' started by mnymkr, Jun 8, 2008.

  1. #1
    I am not quite sure how to ask this,

    currently I am doing form field validation by IF THEN statements and if all fields are filled then I run a simple mail script

    I would like to separate the mail script for better lead tracking

    so I need field validation and then if all fields are filled I need it to go to a separate mail.php script

    Is this possible?
     
    mnymkr, Jun 8, 2008 IP
  2. kenji123

    kenji123 Member

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Yes it is. The best why to do your form validation is by using javascript and then if the form fields are valid then submit the form to mail.php. Here's an example;

    Note the submit button type="button" and not type="submit".
     
    kenji123, Jun 8, 2008 IP
  3. kirpikinzi

    kirpikinzi Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes, it is possible...

    if i understand correctly this is the solution:

    to check the "field" is not empty just use if(isset($_POST['field'])){
    this is a bit easier.
    and to use a seperate mail.php function just use

    require_once ("mail.php");

    function. and if you try to do this in a safe way just add a variable $security="something" and start your mail.php function with if($security=="something") { all the content} else {echo "get out of here :D";}
     
    kirpikinzi, Jun 8, 2008 IP
  4. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #4
    i guess i dont understand how to add the security variable if i was using the

    require_once ("mail.php");

    because it it not a GET URL
     
    mnymkr, Jun 8, 2008 IP