Jump to content

pinheadgunpowdr9

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by pinheadgunpowdr9

  1. Hi guys, sorry for such a newbish question.  Any help would be greatly appreciated.

     

    HTML FORM:

    <form action="form.php" method="post" onsubmit="return validateForm()" name="form">
    <b>First Name:*</b>
    <input type="text" name="first_name" size="50" />
    <b>Last Name:*</b>
    <input type="text" name="last_name" size="50" />
    <b>Phone:*</b>
    <input type="text" name="phone" size="50" />
    <b>Email:*</b>
    <input type="text" name="email" size="50" />
    <p><b>What is your favorite color?*</b></p>
    <p align="left">
    <select name="se">
    <option value="W">White</option>
    <option value="G">Green</option>
    <option value="Y">Yellow</option>
    </select>
    <input type="submit" value="Submit"/>
    </form>
    

     

     

    FORM.PHP script

    <?php
    $se = $_POST['se'];
    $seURL = '';
    switch ($se) {
      case 'W':
        $seURL = "http://url1.com";
        break;
      case 'G':
        $seURL = "http://url2.com";
        break;
      case 'O':
        $seURL = "http://url3.com";
        break;
      default:
        $seURL = "";
    }
    if ($seURL != "") {
    /* Redirect browser */
    /* make sure nothing is output to the page before this statement */
    header("Location: " . $seURL);
    }
    
    // get posted data into local variables
    $EmailFrom = "noreply@domain.com";                           
    $EmailTo = "email@domain.com";                       
    $Subject = "Form";                                         
    $first_name = Trim(stripslashes($_POST['first_name'])); 
    $last_name = Trim(stripslashes($_POST['last_name'])); 
    $phone = Trim(stripslashes($_POST['phone'])); 
    $email = Trim(stripslashes($_POST['email'])); 
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "first_name: ";
    $Body .= $first_name;
    $Body .= "\n";
    $Body .= "last_name: ";
    $Body .= $last_name;
    $Body .= "\n";
    $Body .= "phone: ";
    $Body .= $phone;
    $Body .= "\n";
    $Body .= "email: ";
    $Body .= $email;
    $Body .= "\n";
    $Body .= "color: ";
    $Body .= $se;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // send email to user
    if ($se=="W")
    $EmailFrom = "noreply@domain.com";
    $to = $email;
    $subject = "form email";
    $body = "thank you for filling out our form";
    if (mail($to, $subject, $body, "From: <$EmailFrom>")) {
      echo("<p>Message successfully sent!</p>");
    } else {
      echo("<p>Message delivery failed...</p>");
    }
    
    ?>
    [code]
    
    
    MOD EDIT: [nobbc][code] . . . 
    [/nobbc] tags added . . .[/code]

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.