Jump to content


New Members
  • Posts

  • Joined

  • Last visited

Everything posted by FRASA

  1. I tried this weekend to use <0 in the if/else but the outcome was not as i expected. Now I can see that my problem realy is that I did not use the correct symbol. I hope that my teachers in Math are not reading in this forum. I did not get "less than" and "more than" symbols right. Therefore thoe output did not come out correct. Less than = > More than = < My bad. Thanks for all the help.
  2. The if statement on item5 is not giving me correct output. The line occurs in the mail even if empty or "0". Therefore i have not made it yet for the other items. As a beginner i'm a bit confused. My plan was to use the if/else on the serverside. But as I understand it's not possible. It may only be possible by making a loop to check in the html form. Or?
  3. Sorry mac_gyver. I'm only a beginner in php. I do understand that my code contains a lot of "not the correct way to do it". My only question was if it is possible to do some kind of if/else on the serverside code. From all posts I may conclude that it's not possible.
  4. Hi Requinix Thanks for answering. I will try to explain it more clear and descripe better. (I am aware that mail () is not optimal and not at all with html. Is of course in the process of rewriting so it works with phpmailer.) I have an html form where I want to send data from inputs via mail. In order for the email not to be filled with lines stating that "0" items are being ordered, my thought is that I will test whether $item5 is empty or 0. If it's empty or "0" the line should not be sent in mail. If, on the other hand, there is "1" or more, the line must appear in the email. In the code below, it is only $item5 I have tested on, but the intention is that it is all lines of items to be tested on. I have many lines. More than in the example below <?php if(!isset($_POST['submit'])) { echo "Error; you need to submit the form!"; } $address =$_POST['address']; $tlf =$_POST['tlf']; $date =$_POST['date']; $ordernote =$_POST['ordernote']; $project =$_POST['project']; $item1 = $_POST['DW']; $item2 = $_POST['DW1']; $item3 = $_POST['AF1']; $item4 = $_POST['AF2']; $item5 = $_POST['PIGM1']; $visitor_mail = $_POST['visitormail']; $visitor_name = $_POST['visitorname']; //Validate if(empty($address)||empty($tlf)) { echo "Address and tlf need to be filled"; exit; } $email_from = 'some@mail.com'; $email_subject = 'My subject'; $email_body = '<html><head><style type="text/css">td { width: 450; }</style></head><body>'; $email_body .= '<h2>New form submitted</h2>'; $email_body .= '<table border="0" width="900">'; $email_body .= '<tr><td><strong>Info:</strong></td><td></td></tr>'; $email_body .= '<tr><td><strong>Address:</strong></td><td>' . $adresse . '</td></tr>'; $email_body .= '<tr><td><strong>Phone:</strong></td><td>' . $tlf . '</td></tr>'; $email_body .= '<tr><td><strong>Date:</strong></td><td>' . $date . '</td></tr>'; $email_body .= '<tr><td><strong>Project number:</strong></td><td>' . $project . '</td></tr>'; $email_body .= '<tr><td><strong>Notes:</strong></td><td>' . $ordernote . '</td></tr>'; $email_body .= '</table><br />'; $email_body .= '<table border="0" width="900">'; $email_body .= '<tr><td><strong>Items info:</strong></td><td></td></tr>'; $email_body .= '<tr><td></td><td>' . $item1 . '&nbsp; pcs. of item 1 is ordered</td></tr>'; $email_body .= '<tr><td></td><td>' . $item2 . '&nbsp; pcs. of item 2 is ordered</td></tr>'; $email_body .= '<tr><td></td><td>' . $item3 . '&nbsp; pcs. of item 3 is ordered</td></tr>'; $email_body .= '<tr><td></td><td>' . $item4 . '&nbsp; pcs. of item 4 is ordered</td></tr>'; //if (empty($vare5)) { // echo '$email_body .= "";'; //} if (isset($item5)) { $email_body .= '<tr><td></td><td>' . $item5 . '&nbsp; pcs. of item 5 is ordered</td></tr>'; } $email_body .= '</table><br />'; $email_body .= '</body></html>'; $to = "destination@mail.com"; $headers = "From: Project form <". $email_from .">\r\n"; //$headers .= "Cc: <". $visitor_mail .">"\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $headers .= "X-Mailer: PHP/" . phpversion(); mail($to,$email_subject,$email_body,$headers); header('Location: thank-you.html'); ?>
  5. Hi I'm a beginner in php and are facing a problem i cant seem to find the correct solution on. I have crated a large html form where i't sends mail with vaules from the inputs in an HTML mail. I would like to check if there is a value from the form, and if there is i need to put the value in the mail. If not, then nothing from that input will be written. So far my thoughts have been like this:(just a sniplet of my actionpage.php $item5 = $_POST['PIGM1']; if (empty($item5)) { $email_body .= ''; } if (isset($item5)) { $email_body = '<html><head><style type="text/css">td { width: 450; }</style></head><body>'; $email_body .= '<table border="0" width="900">'; $email_body .= '<tr><td><strong>Header in table</strong></td><td></td></tr>'; $email_body .= '<tr><td><strong>Ordered</strong></td><td>' . $item5 . ' pcs. of some item</td></tr>'; $email_body .= '</table><br />'; } Can anyone help me in the right direction?
  • 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.