Jump to content

CBG

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by CBG

  1. I have a set of if else for each of d, c and o to change the answer to either be Yes or No to check for in the code, using the below. It check the value from the form checkbox, this is working fine. if ($d == "D") { $d = "Yes"; } else { $d = "No"; } if ($c == "C") { $c = "Yes"; } else { $c = "No"; } if ($o == "O") { $o = "Yes"; } else { $o = "No"; }
  2. Thanks for the help, to you both, it is very much appreciated. It will always be a capital Y in Yes as it the value is hardcoded in the form on the checkbox in the form. If it not a capital Y, it need to fail anyway, as it means something gone wrong somewhere. I will give this a try in a bit, and mark up the solution.
  3. Would this give the option to do under the following examples below? Should of done this in the begin Here are the examples I need the statement to do: Example 1 - p No - Do nothing else p No Continue and do nothing Example 2 - p Yes, o Yes - Continue p Yes - Now change if one fo the following is Yes: d or c or o if not give an error d No c No o Yes Continue and do nothing Example 3 - p Yes, c Yes - Continue p Yes - Now change if one fo the following is Yes: d or c or o if not give an error d No c Yes o No Continue and do nothing Example 4 - p Yes, d Yes - Continue p Yes d Yes c No o No Continue and do nothing Example 5 - p Yes, d,c and o are No - give an error p Yes d No c No o No Give an error
  4. The way I need it to work is: If $p is No, then ignore and continue If $p is Yes I then need to check if one of the following $d, $c or $o is Yes If not it give an the error
  5. Hi, I am having a problem with this if and or statement. It is a part of my form validation. But if give the same error regardless The way I need it to work is like this: $p, $d, $c and $o can all be Yes or No If $p is Yes I then need to check if $d, $c or $o is Yes If not it give an the error This is the current code I have. I have tried the same code without brackets before the or part, but it give the same problem if ($p == "Yes" && ($d != "Yes" || $c != "Yes" || $o != "Yes")) { echo "error"; } Any help or fix would be great, I am sure it something silly, or maybe I got it the wrong way around or something silly like that. Thanks
  6. I have tried if like this $subject = 'Subject'; $message = 'Message goes here' . "\r\n" . 'Name: ' . $name . "\r\n" . if ($doesthishavedata != ''){ 'Does this have data: ' . $doesthishavedata . "\r\n" . } 'something else: ' . $hasdata . "\r\n" . '------------------------------------'; But get an error PHP Parse error: syntax error, unexpected 'if' (T_IF) Now if there away to break up the message into bits, then I could most likely use an if Would this work to break the message up $subject = 'Subject'; $message = 'Message goes here'; $message .= 'Name: ' . $name; $message .= 'Does this have data: ' . $doesthishavedata; $message .= 'something else: ' . $hasdata; $message .= '------------------------------------';
  7. Hi, I am using PHP to send an text email message after a form is submitted Use mail at the moment, to send a text email for example: $subject = 'Subject'; $message = 'Message goes here' . "\r\n" . 'Name: ' . $name . "\r\n" . 'Does this have data: ' . $doesthishavedata . "\r\n" . 'something else: ' . $hasdata . "\r\n" . '------------------------------------'; $to = '[email protected]'; $from = '[email protected]'; $headers = 'From: ' . $from . '' . "\r\n" . 'Reply-To: ' . $from . '' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail ($to, $subject, $message, $headers); As you can see Does this have data part, if it does not how can I remove it from being sent in the email? Thanks
×
×
  • 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.