Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Simple PHP form processing help please

Hi there. I'm trying to write a php script that will email the contents of a form to two people. It doesn't have to be fancy, the data just needs to be clear in the email. I know almost nothing about PHP so I need someone's help. I've included the the form and the php I have so far (not much).

<FORM ACTION="formprocess.php" NAME="invoice">

<TABLE CELLPADDING="10" CELLSPACING="0" BORDER="0">
<TR>
      <TD COLSPAN="2"><IMG SRC="images/logo_premier_invoice.jpg"><BR><BR>
      <B>Please fill out this quick form and click here --> <INPUT TYPE="submit" VALUE="Send" style="background-color:yellow;"> to email us and our customs broker.</B><BR></TD>
</TR>
<TR>
      <TD WIDTH="100"><B>Full Name</TD>
      <TD WIDTH="400"><INPUT NAME="customer_name" TYPE="text" SIZE="40"></TD>
</TR>
<TR>
      <TD WIDTH="100"><B>Company</TD>
      <TD WIDTH="400"><INPUT NAME="company_name" TYPE="text" SIZE="40"></TD>
</TR>
<TR>
      <TD WIDTH="100"><B>Carrier #</TD>
      <TD WIDTH="400"><INPUT NAME="carrier" TYPE="text" SIZE="20"></TD>
</TR>
      <TD><B>Tracking #</TD>
      <TD><INPUT NAME="tracking" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
      <TD><B>Our P.O. #</TD>
      <TD><INPUT NAME="po" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
      <TD><B># of Pieces or Pallets</TD>
      <TD><INPUT NAME="pieces" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
      <TD><B>Weight</TD>
      <TD><INPUT NAME="weight" TYPE="text" SIZE="20"></TD>
</TR>

</TABLE>


**************formprocess.php

<?PHP

$recipient = 'greig@premier-lighting.net, kdaniels@summitcustombrockers.com';
$subject = 'Canada Customs Invoice';

$customer_name = $_POST['customer_name'];
$company_name $_POST['company_name'];
$carrier_number = $_POST['carrier'];
$tracking_number = $_POST['tracking'];
$po_number = $_POST['po'];
$pieces_number = $_POST['pieces'];
$weight_number = $_POST['weight'];

?>

0
flipside1212
Asked:
flipside1212
2 Solutions
 
jaysefCommented:
The mail() function is all that you'll have to use.

mail("toaddress@isp.com", "Subject", "Message - Usually a variable")

If you want to get fancy and add a from address, you go:
mail("toaddress@isp.com", "Subject", "Message - Usually a variable", "From: email@email.com")

You can put all of the data into one variable (so your body is nice), you would go
$message = $String1 . $String2
Using that idea, you could add new lines with
$message = $String1 . "\n" . $String2
Your data will come out nice and emailed.
0
 
designbaiCommented:
to send mail using PHP you have use mail function.

for more details on mail function check here
http://www.php.net/manual/en/ref.mail.php

You can use this if you want to send a plain text email. If you want it to be fancy, you can always design according to your needs and change the content-type in the header.



<?PHP

if (isset($_REQUEST['submit']) && $_REQUEST['submit'] == "Send") {

      $recipient = 'greig@premier-lighting.net, kdaniels@summitcustombrockers.com'

      $customer_name = $_REQUEST['customer_name'];
      $company_name = $_REQUEST['company_name'];
      $carrier_number = $_REQUEST['carrier'];
      $tracking_number = $_REQUEST['tracking'];
      $po_number = $_REQUEST['po'];
      $pieces_number = $_REQUEST['pieces'];
      $weight_number = $_REQUEST['weight'];
      
      $contents = "Customer Name : ".$customer_name."\n";
      $contents .= "Company Name : ".$company_name."\n";
      $contents .= "Carrier Number : ".$carrier_number."\n";
      $contents .= "Tracking Number : ".$tracking_number."\n";
      $contents .= "Post Box Number : ".$po_number."\n";
      $contents .= "Pieces Number : ".$pieces_number."\n";
      $contents .= "Weight Number : ".$weight_number."\n";
      
                /* specify some headers. */
      $headers  = "MIME-Version: 1.0\r\n";
      
      
      // if you want to send html email change content-type to text/html
      
      $headers .= "Content-type: text/plain; charset='UTF-8' http-equiv='Content-Type' \r\n";

      /* additional headers */
      // this is your from address
      $headers .= "From:your@email.address\r\n";
      
      // reply should redirect to
      $headers .= "Reply-To:yourreply@email.address\r\n";

      $subject = 'Canada Customs Invoice';
      
      if (mail($recipient,$subject,$contents,$headers)) {
            echo "Message sent successfully";

      } else {
            echo "Error sending mail";
      }
            exit;


}

?>

<FORM ACTION="formprocess.php" NAME="invoice" method="POST">

<TABLE CELLPADDING="10" CELLSPACING="0" BORDER="0">
<TR>
     <TD COLSPAN="2"><IMG SRC="images/logo_premier_invoice.jpg"><BR><BR>
     <B>Please fill out this quick form and click here --> <INPUT TYPE="submit" VALUE="Send" name ="submit" style="background-color:yellow;"> to email us and our customs broker.</B><BR></TD>
</TR>
<TR>
     <TD WIDTH="100"><B>Full Name</TD>
     <TD WIDTH="400"><INPUT NAME="customer_name" TYPE="text" SIZE="40"></TD>
</TR>
<TR>
     <TD WIDTH="100"><B>Company</TD>
     <TD WIDTH="400"><INPUT NAME="company_name" TYPE="text" SIZE="40"></TD>
</TR>
<TR>
     <TD WIDTH="100"><B>Carrier #</TD>
     <TD WIDTH="400"><INPUT NAME="carrier" TYPE="text" SIZE="20"></TD>
</TR>
     <TD><B>Tracking #</TD>
     <TD><INPUT NAME="tracking" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
     <TD><B>Our P.O. #</TD>
     <TD><INPUT NAME="po" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
     <TD><B># of Pieces or Pallets</TD>
     <TD><INPUT NAME="pieces" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
     <TD><B>Weight</TD>
     <TD><INPUT NAME="weight" TYPE="text" SIZE="20"></TD>
</TR>

</TABLE>

hope this helps.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now