Menu

Filter out empty text fields or boxes

Help
Martzee
2010-12-07
2013-06-03
  • Martzee

    Martzee - 2010-12-07

    I have a form with a lot of textboxes and text fields. Most of them are not required to fill by the user. Is there any simple way to filter out those fields and boxes which the user left empty so the mail() sends only filled lines (text fields or textboxes)?
    Thanks for your help.

     
  • TNTEverett

    TNTEverett - 2010-12-10

    In your processor.php file, change something like this

    mail("you@yoururl.com","phpFormGenerator - Form submission","Form data:
    Name: " . $_POST . "
    State of residence: " . $_POST . "
    Email: " . $_POST . "
    powered by phpFormGenerator.
    ");

    to something like this

    $message="Form data:";
    if($_POST) {$message.="Name: " . $_POST . "\r\n"}
    if($_POST) {$message.="State of residence: " . $_POST . "\r\n"}
    if($_POST) {$message.="Email: " . $_POST . "\r\n"}
    $message.="powered by phpFormGenerator.";

    mail("you@yoururl.com","phpFormGenerator - Form submission",$message);

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.