www.webdeveloper.com
Results 1 to 2 of 2

Thread: Form processing

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    9

    Form processing

    Hi I wrote following form processing script that I got partially to work. everything works (validation and adding name and email to header), but I can't get it to add the content in the body, I have saved all contents in the variable $body here it is:


    function VerifyForm(&$values, &$errors)
    {

    if (strlen($values['name']) < 3)
    $errors['name'] = 'Name too short';
    elseif (strlen($values['name']) > 40)
    $errors['name'] = 'Name too long';




    if (!ereg('.*@.*\..{2,4}', $values['email']))
    $errors['email'] = 'Email address invalid';



    else {if(isset($_POST['submit'])){


    }

    $products = $_POST['products'];
    $colors = $_POST['colors'];
    $start = $_POST['start'];
    $deadline = $_POST['deadline'];
    $budget = $_POST['budget'];
    $comment= $_POST['comment'];
    };


    return (count($errors) == 0);









    }

    function DisplayForm($values, $errors)
    {


    $body = "Confirmation: $confirm\n\n\n
    Name: $name\n
    Email: $email\n

    Company: $company\n

    Services selected:\n
    $graphic\n\n
    products: $products\n
    colors: $colors\n
    When Would you like to start: $start\n
    Project deadline: $deadline\n
    Budget: $budget\n

    Details/Comments :$comment

    ";

    <form>
    all field are here
    </form>


    </body>

    </html>
    <?php
    }




    function ProcessForm($values)
    {
    mail('myemail@domain.com', "response" , $body, "From: \"{$values['name']}\ <{$values['email']}>");

    echo "Sent ";
    }

    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    $formValues = $_POST;
    $formErrors = array();

    if (!VerifyForm($formValues, $formErrors))
    DisplayForm($formValues, $formErrors);
    else
    ProcessForm($formValues);
    }
    else
    DisplayForm(null, null);
    ?>
    Last edited by andy106; 02-12-2011 at 02:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles