Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove specific definitions from a variable in PHP
    primarykey
    data
    text
    <p>I have a PHP mail script that validates name, email address, and phone number before sending the mail. This then means that the Name, Email address, and Phone fields are <strong>Required</strong> Fields. </p> <p>I want to have it so that the <em>Name</em> and <strong><em>EITHER</em></strong> <em>Email</em> or <em>Phone</em> are required. Such that if a name and phone are inputted, it sends the mail, or if a name and an email are inputted, it also sends the email. </p> <p>The way the script works right now is it has several IF statements that check for (1) name, (2) email and (3) phone. Here's an example of an if statement of the code:</p> <pre><code>if ( ($email == "") ) { $errors .= $emailError; // no email address entered $email_error = true; } if ( !(preg_match($match,$email)) ) { $errors .= $invalidEmailError; // checks validity of email $email_error = true; } </code></pre> <p>And here's how it sends the mail:</p> <pre><code> if ( !($errors) ) { mail ($to, $subject, $message, $headers); echo "&lt;p id='correct'&gt;"; echo "ההודעה נשלחה בהצלחה!"; echo "&lt;/p&gt;"; } else { if (($email_error == true)) { $errors != $phoneError; /*echo "&lt;p id='errors'&gt;"; echo $errors; echo "&lt;/p&gt;";*/ } if (($phone_error == true)) { $errors != $emailError; $errors != $invalidEmailError; /*echo "&lt;p id='errors'&gt;"; echo $errors; echo "&lt;/p&gt;";*/ } echo "&lt;p id='errors'&gt;"; echo $errors; echo "&lt;/p&gt;"; } </code></pre> <p>This doesn't work though. Basically this is what I want to do: If no email address was entered or if it was entered incorrectly, set a variable called $email_error to be true. Then check for that variable, and if it's true, then remove the $phoneError part of the $errors variable.</p> <p>Man I hope I'm making some sense here. Does anyone know why this doesn't work? It reports all errors if all fields are left empty :(</p> <p>Thanks! Amit</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload