Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>so...</p> <pre><code>$sent=false; if(!$name){ $errors[]='No Name was supplied.'; return($errors); } if($phone &amp;&amp; validatePhone($phone)){ //send the phone message however... $sent=true; } if($email &amp;&amp; validateEmail($email)){ //send the email here... $sent=true; } if(!$sent){ $errors[]='Neither an email or a phone was supplied'; return($errors); } </code></pre> <p>classed:</p> <pre><code>class Communication { var $sent=false; var $errors=false; public function __construct(){ $this-&gt;phone=$_POST['phone']; $this-&gt;email=$_POST['email']; $this-&gt;name=$_POST['name']; if($this-&gt;validateName()){ $this-&gt;validateEmail(); $this-&gt;validatePhone(); } } public function validateEmail(){ //do your regex here and eval either false or true to $status if(!$status){ $this-&gt;errors['ErrorInvalidEmail']=ErrorInvalidEmail; }else{ $this-&gt;sendEmail(); } } public function validatePhone(){ //do your regex here and eval either false or true to $status if(!$status){ $this-&gt;errors['ErrorInvalidPhone']=ErrorInvalidPhone; }else{ $this-&gt;sendText(); } } public function validateName(){ //do your regex here and eval either false or true to $status if(!$status){ $this-&gt;errors['ErrorInvalidName']=ErrorInvalidName; return(false); }else{ return(true); } } public function sendEmail(){ $this-&gt;sent=true; //do your sending by email HERE } public function sendText(){ $this-&gt;sent=true; // do your sending by text/phone here } } $c=new Communication(); print_r($c-&gt;errors); </code></pre>
 

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