97 users online (2 members and 95 guests)  

Thread: PHP Form

  Results 1 to 3 of 3


  1. Replies: 1
  2. Replies: 4
  3. Replies: 1
  4. Form Handling Script for 'Tell A Friend' Form    Forum: Javascript Forum
    Replies: 1
  5. Replies: 3
  1. #1
    mcbone's Avatar
    New User

    Join Date
    Dec 2006

    PHP Form

    Hello to all, my friend suggested a visited to yourselves, he mentioned you were a helpful friendly bunch

    I wonder if you could help me, i work in hand code, and im pretty good in html and java, but anything more i'm not great!!

    I have been stuck on a problem now for a number of days and finally admit i need help.

    I'm making a simple form for a site, with 5 optional text fields:

    (name, address, postcode, home phone number, mobile phone number)

    one drop down with 5 options (how can i help) (required field)

    and a text area (tell me more) (required field)

    and i want it to forward to an email address, i dont need it stored in a txt file, just email forwaring, and i need to use php as its an anonymous form.

    I have made the form numerous times, and the .php handler file, but with no luck!!

    I was wondering/hoping whether someone had some old crude code lying about somewhere, or if someone could help me somehow.

    Thanks for you time, i appreciate it greatly

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Join Date
    Feb 2005

    Re: PHP Form

    quite simple:

    in the html file have the <form> tag's action tag link to the php file.

    in the php file use this:
    PHP Code:
    //set this value to the page you want them to go too when they are done
    $thankyoupage "done.htm";

    //set these values to the appropriate thing...
    //The first item in the []'s should be the name of the input type EXACTLY
    $required_fields['name']['required'] = true;
    $required_fields['name']['err_msg'] = 'You must fill out the name field';
    $required_fields['address']['required'] = true;
    $required_fields['address']['error_msg'] = 'You must fill out the address field';
    $required_fields['postcode']['required'] = true;
    $required_fields['postcode']['error_msg'] = 'You must fill out the postal code';
    $required_fields['phone']['required'] = true;
    $required_fields['phone']['error_msg'] = 'You must fill out the phone number field';
    $required_fields['mobile']['required'] = true;
    $required_fields['mobile']['error_msg'] = 'You must populate the mobile field';
    $required_fields['how can i help']['required'] = true;
    $required_fields['how can i help']['error_msg'] = 'You must provide a "how i can help"';
    $required_fields['tell me more']['required'] = true;
    $required_fields['tell me more']['error_msg'] = 'You must provide info in the "Tell me More" section"';

    $required_fields as $key => $value){
    $_POST[$key]) && $value['required']){
    $error_msg[] = $value['error_msg'];
    $_POST[$key] && $value['required']){
    $error_msg[] = $value['error_msg'];
    $error_msg as $key => $value){
        <b>Please use the back button and correct the errors</b>"
    $to 'email@domain.com';

    // subject
    $subject 'Subject';

    // message
    foreach($required_fields as $key => $value){
    $message .= "$key:\n     $_POST[$key]\n";
    // from
    $from "fromaddress@domain.com";

    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/plain; charset=iso-8859-1' "\r\n";

    // Additional headers
    $headers .= 'To: $to' "\r\n";
    $headers .= 'From: Rental Request <$from>' "\r\n";

    // Mail it
    header("Location: $thankyoupage");
    This will create a few notices, but notices should be turned off on a public web server.

    It should be simple enough to setup if you already know some php. just set those top variables and the mail variables toward the bottom to what they should be and it should work... however i did not test it, because i didnt feel the need.


  3. #3
    mcbone's Avatar
    New User

    Join Date
    Dec 2006

    Re: PHP Form

    thank you for that!!

    just gonna try it out now!

Tags for this Thread