WEB Need form help

Discussion in 'OT Technology' started by AnoesisX, Jun 2, 2008.

  1. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    I need an email form php generator anyone know of any that works?
     
  2. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    form.php
    Code:
    <?
    
    foreach($_POST as $key=>$value) {
    			    
    	$emailBody .= "$key : $value\n";
    
    }
    
    $to = [email protected]';
    $subject = 'form submit';
    
    mail($to, $subject, $emailBody);
    
    ?>
    
     
  3. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    form.htm
    Code:
    <html>
    <body>
    <form action="form.php">
    Name: <input type="text" name="name"><br>
    Comment: <input type='text" name="comment"><br><br>
    <input type="submit">
    </form>
    </body>
    </html>
    
     
  4. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    Parse error: parse error, unexpected '=' in Line 27

    I'm getting Parse error: parse error, unexpected '=' in Line 27 error
    Line 27 is $CityStateZip = Trim(stripslashes($_POST['CityStateZip']));
    any help?
    Code:
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
    
    $EmailTo = "[email protected]";
    
    $Subject = "Placement form";
    
    $DebtorName = Trim(stripslashes($_POST['DebtorName'])); 
    
    $AmountDue = Trim(stripslashes($_POST['AmountDue'])); 
    
    $Address = Trim(stripslashes($_POST['Address'])); 
    
    $CityStateZip = Trim(stripslashes($_POST['CityStateZip'])); 
    
    $Telephone = Trim(stripslashes($_POST['Telephone'])); 
    
    $Dateofoldestunpaidinvoice = Trim(stripslashes($_POST['Dateofoldestunpaidinvoice'])); 
    
    $IndividualResponsible = Trim(stripslashes($_POST['IndividualResponsible'])); 
    
    $OtherNumbers = Trim(stripslashes($_POST['OtherNumbers'])); 
    
    $DebtorsBank = Trim(stripslashes($_POST['DebtorsBank'])); 
    
    $Productormerchandisesold = Trim(stripslashes($_POST['Productormerchandisesold'])); 
    
    $Whatwassaidonthelastcall = Trim(stripslashes($_POST['Whatwassaidonthelastcall'])); 
    
    $AccountNumber = Trim(stripslashes($_POST['AccountNumber'])); 
    
    $MiscInfo = Trim(stripslashes($_POST['MiscInfo'])); 
    
    $YourCompanyName = Trim(stripslashes($_POST['YourCompanyName'])); 
    
    $YourAddress = Trim(stripslashes($_POST['YourAddress'])); 
    
    $YourCityStateZip = Trim(stripslashes($_POST['YourCityStateZip'])); 
    
    $YourTelephone = Trim(stripslashes($_POST['YourTelephone'])); 
    
    $Fax = Trim(stripslashes($_POST['Fax'])); 
    
    $Email = Trim(stripslashes($_POST['Email'])); 
    
    $AuthorizedBy = Trim(stripslashes($_POST['AuthorizedBy'])); 
    
    $Date = Trim(stripslashes($_POST['Date'])); 
    
    
    
    // validation
    
    $validationOK=true;
    
    if (Trim($EmailFrom)=="") $validationOK=false;
    
    if (!$validationOK) {
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    
      exit;
    
    }
    
    
    
    // prepare email body text
    
    $Body = "";
    
    $Body .= "DebtorName: ";
    
    $Body .= $DebtorName;
    
    $Body .= "\n";
    
    $Body .= "AmountDue: ";
    
    $Body .= $AmountDue;
    
    $Body .= "\n";
    
    $Body .= "Address: ";
    
    $Body .= $Address;
    
    $Body .= "\n";
    
    $Body .= "City/State/Zip: ";
    
    $Body .= $City/State/Zip;
    
    $Body .= "\n";
    
    $Body .= "Telephone: ";
    
    $Body .= $Telephone;
    
    $Body .= "\n";
    
    $Body .= "Dateofoldestunpaidinvoice: ";
    
    $Body .= $Dateofoldestunpaidinvoice;
    
    $Body .= "\n";
    
    $Body .= "IndividualResponsible: ";
    
    $Body .= $IndividualResponsible;
    
    $Body .= "\n";
    
    $Body .= "OtherNumbers: ";
    
    $Body .= $OtherNumbers;
    
    $Body .= "\n";
    
    $Body .= "DebtorsBank: ";
    
    $Body .= $DebtorsBank;
    
    $Body .= "\n";
    
    $Body .= "Productormerchandisesold: ";
    
    $Body .= $Productormerchandisesold;
    
    $Body .= "\n";
    
    $Body .= "Whatwassaidonthelastcall: ";
    
    $Body .= $Whatwassaidonthelastcall;
    
    $Body .= "\n";
    
    $Body .= "AccountNumber: ";
    
    $Body .= $AccountNumber;
    
    $Body .= "\n";
    
    $Body .= "MiscInfo: ";
    
    $Body .= $MiscInfo;
    
    $Body .= "\n";
    
    $Body .= "YourCompanyName: ";
    
    $Body .= $YourCompanyName;
    
    $Body .= "\n";
    
    $Body .= "YourAddress: ";
    
    $Body .= $YourAddress;
    
    $Body .= "\n";
    
    $Body .= "YourCity/State/Zip: ";
    
    $Body .= $YourCity/State/Zip;
    
    $Body .= "\n";
    
    $Body .= "YourTelephone: ";
    
    $Body .= $YourTelephone;
    
    $Body .= "\n";
    
    $Body .= "Fax: ";
    
    $Body .= $Fax;
    
    $Body .= "\n";
    
    $Body .= "Email: ";
    
    $Body .= $Email;
    
    $Body .= "\n";
    
    $Body .= "AuthorizedBy: ";
    
    $Body .= $AuthorizedBy;
    
    $Body .= "\n";
    
    $Body .= "Date: ";
    
    $Body .= $Date;
    
    $Body .= "\n";
    
    
    
    // send email 
    
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    
    
    // redirect to success page 
    
    if ($success){
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
    
    }
    
    else{
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    
    }
    
    ?>
    
    
     
  5. Josh

    Josh Guest

    trim is all lowercase unless you define Trim
     
  6. Deviance

    Deviance Can't you smell that smell? OT Supporter

    Joined:
    Jul 10, 2007
    Messages:
    4,988
    Likes Received:
    12
    Location:
    Rocky Mountain High
    I use PHP Multiform Generator with phpmyedit.

    Works well.
     
  7. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    how do you use those? Do I upload them yo my server and open it in there or what.
     
  8. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Yanno.

    Code:
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
    
    $DebtorName = Trim(stripslashes($_POST['DebtorName'])); 
    
    $AmountDue = Trim(stripslashes($_POST['AmountDue'])); 
    
    $Address = Trim(stripslashes($_POST['Address'])); 
    
    $CityStateZip = Trim(stripslashes($_POST['CityStateZip'])); 
    
    $Telephone = Trim(stripslashes($_POST['Telephone'])); 
    
    $Dateofoldestunpaidinvoice = Trim(stripslashes($_POST['Dateofoldestunpaidinvoice'])); 
    
    $IndividualResponsible = Trim(stripslashes($_POST['IndividualResponsible'])); 
    
    $OtherNumbers = Trim(stripslashes($_POST['OtherNumbers'])); 
    
    $DebtorsBank = Trim(stripslashes($_POST['DebtorsBank'])); 
    
    $Productormerchandisesold = Trim(stripslashes($_POST['Productormerchandisesold'])); 
    
    $Whatwassaidonthelastcall = Trim(stripslashes($_POST['Whatwassaidonthelastcall'])); 
    
    $AccountNumber = Trim(stripslashes($_POST['AccountNumber'])); 
    
    $MiscInfo = Trim(stripslashes($_POST['MiscInfo'])); 
    
    $YourCompanyName = Trim(stripslashes($_POST['YourCompanyName'])); 
    
    $YourAddress = Trim(stripslashes($_POST['YourAddress'])); 
    
    $YourCityStateZip = Trim(stripslashes($_POST['YourCityStateZip'])); 
    
    $YourTelephone = Trim(stripslashes($_POST['YourTelephone'])); 
    
    $Fax = Trim(stripslashes($_POST['Fax'])); 
    
    $Email = Trim(stripslashes($_POST['Email'])); 
    
    $AuthorizedBy = Trim(stripslashes($_POST['AuthorizedBy'])); 
    
    $Date = Trim(stripslashes($_POST['Date'])); 
    
    // prepare email body text
    
    $Body = "";
    
    $Body .= "DebtorName: ";
    
    $Body .= $DebtorName;
    
    $Body .= "\n";
    
    $Body .= "AmountDue: ";
    
    $Body .= $AmountDue;
    
    $Body .= "\n";
    
    $Body .= "Address: ";
    
    $Body .= $Address;
    
    $Body .= "\n";
    
    $Body .= "City/State/Zip: ";
    
    $Body .= $City/State/Zip;
    
    $Body .= "\n";
    
    $Body .= "Telephone: ";
    
    $Body .= $Telephone;
    
    $Body .= "\n";
    
    $Body .= "Dateofoldestunpaidinvoice: ";
    
    $Body .= $Dateofoldestunpaidinvoice;
    
    $Body .= "\n";
    
    $Body .= "IndividualResponsible: ";
    
    $Body .= $IndividualResponsible;
    
    $Body .= "\n";
    
    $Body .= "OtherNumbers: ";
    
    $Body .= $OtherNumbers;
    
    $Body .= "\n";
    
    $Body .= "DebtorsBank: ";
    
    $Body .= $DebtorsBank;
    
    $Body .= "\n";
    
    $Body .= "Productormerchandisesold: ";
    
    $Body .= $Productormerchandisesold;
    
    $Body .= "\n";
    
    $Body .= "Whatwassaidonthelastcall: ";
    
    $Body .= $Whatwassaidonthelastcall;
    
    $Body .= "\n";
    
    $Body .= "AccountNumber: ";
    
    $Body .= $AccountNumber;
    
    $Body .= "\n";
    
    $Body .= "MiscInfo: ";
    
    $Body .= $MiscInfo;
    
    $Body .= "\n";
    
    $Body .= "YourCompanyName: ";
    
    $Body .= $YourCompanyName;
    
    $Body .= "\n";
    
    $Body .= "YourAddress: ";
    
    $Body .= $YourAddress;
    
    $Body .= "\n";
    
    $Body .= "YourCity/State/Zip: ";
    
    $Body .= $YourCity/State/Zip;
    
    $Body .= "\n";
    
    $Body .= "YourTelephone: ";
    
    $Body .= $YourTelephone;
    
    $Body .= "\n";
    
    $Body .= "Fax: ";
    
    $Body .= $Fax;
    
    $Body .= "\n";
    
    $Body .= "Email: ";
    
    $Body .= $Email;
    
    $Body .= "\n";
    
    $Body .= "AuthorizedBy: ";
    
    $Body .= $AuthorizedBy;
    
    $Body .= "\n";
    
    $Body .= "Date: ";
    
    $Body .= $Date;
    
    $Body .= "\n";
    
    Can be replaced by:

    Code:
    foreach($_POST as $key=>$value) {
    			    
    	$Body .= "$key: " . trim(stripslashes($value)) . "\n";
    
    }
    
    It will output the same exact thing.
     
  9. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    OK i Got it to work but Now when i click submit the form sends to my email but it goes to the error page instead of the success page
    thanks for your help
    Code:
    <?
    
    foreach($_POST as $key=>$value) {
                    
        $emailBody .= "$key : $value\n";
    
    }
    
    $to = [email protected]';
    $subject = 'Placement form';
    
    mail($to, $subject, $emailBody);
    
    // redirect to success page 
    
    if ($success){
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=placementsent.html\">";
    
    }
    
    else{
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    
    }
    
    
    ?>
     
  10. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    You don't define $success so your if statement will always be false (because it's blank/null).

    I think you want

    $success = mail($to, $subject, $emailBody);

    You may also want to change the foreach loop to be "$key: " . trim(stripslashes($value)) . "\n"; instead of "$key : $value\n"; -- it'll give you cleaner results.
     
  11. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    Ok everything worked fine on my server ( sends the email then goes to a success page) but when I uploaded it to the server that it needs to be on it when i click submit it goes to the actual php page and shows
    Code:
    $value) {                      $emailBody .= "$key: " . trim(stripslashes($value)) . "\n";  }  $to = [email protected]'; $subject = 'Placement form';  $success = mail($to, $subject, $emailBody);  // redirect to success page   if ($success){    print "";  }  else{    print "";  }   ?>
     
  12. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Make sure you're uploading as ASCII as opposed to BINARY (in your FTP program). I've also had uploads fail and a re-upload fixes them.
     

Share This Page