troubleshooting Question

Server side validation (retaining variables)

Avatar of burnedfaceless
burnedfaceless asked on
PHPWeb Development Software
29 Comments2 Solutions358 ViewsLast Modified:
Here's what I'm going for...some text (that should be easy) but assuming we have to reload the page how do we keep variables for customer.

<?php
   
$result=TRUE;      
   
 function check_email($email)
      {
      
            if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
            $result = FALSE; //enter text here
      }
//  return $result; probably unnecessary to return variable if can write within the function
}

      

      if (strlen($first) > 0)
      {
            $result = FALSE;//enter text
      }
      if (strlen($last) > 0)
      {
            $result = FALSE;//enter text
      }
      if (strlen($from) > 0)
      {
            $result = FALSE;//enter text
      }
      if (strlen($addy) > 0)
      {
            $result = FALSE;
      }
      if (strlen($reason) > 0)
      {
            $result = FALSE;
      }
      if (strlen($message) > 0)
      {
            $result = FALSE;
      }
      
      
      
?>

<form name = "contact" id = "contact" method = "post" action = "php/mailer.php" onSubmit = "return validate ();">      
      <fieldset id = "contactinformation">            
      <legend>Your Information</legend>            
      <label class = "blocklabel">            
            First Name:      <input type = "text" id = "fname" name = "fname" /><br/>            
      </label>            
      <label class = "blocklabel">            
            Last Name: <input type = "text" id = "lname" name = "lname" /><br/>            
      </label>            
      <label class = "blocklabel">            
            Email Address: <input type = "text" id = "email" name = "email" /><br/>            
      </label>            
      <label class = "blocklabel">            
            Mailing address: <input type = "text" id = "address" name = "address">            
      </label>            
      For what reason are you contacting us?<br/>                  
      <input type = "radio" id = "complaint" name = "ts" value = "Complaint" />Complaint                  
      <input type = "radio" id = "inquiry" name = "ts" value = "Inquiry" />Inquiry                  
      <input type = "radio" id = "comment" name = "ts" value ="Comment" />Comment                  
      <input type = "radio" id = "other" name = "ts" value = "Other" />Other      
      </fieldset>      
      <fieldset id = "message">            
            <legend>Enter your message below</legend>            
            <textarea name="comments" cols="40" rows="5"></textarea><br/>      
      </fieldset>            
      <input type = "submit" value = "Submit" />      <input type = "reset" value = "Clear" />
      </form>

edited to put result variable before function
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 29 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 29 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros