tommywij Posted February 10, 2014 Share Posted February 10, 2014 (edited) Hi, I'm newbie here. I need some help regarding form handling, here is my code <?php if($_SERVER['REQUEST_METHOD']=='POST') { if(isset($_POST['name'])) { $name = test_input($_POST['name']); $nameErr=validateName($name); } if(isset($_POST['email'])) { $email = test_input($_POST['email']); $emailErr=validateEmail($email); } if($nameErr="" and $emailErr="") { UpdateConfig(); } } ?> <form method="post" action="" style="margin-left:60px"> Name : <input type="text" name="name"> <span class="error">* <?php if($name!=""){echo $nameErr;} ?></span> <br> E-mail: <input type="text" name="email"> <span class="error">* <?php echo $emailErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> My problem occur on the error message that echo within the class error, email error is showing but name error isn't. I've tried to echo both var nameErr and emailErr within the php bracket and it is showing nicely, but still it is not showing on line <span class="error">* <?php if($name!=""){echo $nameErr;} ?></span> this is kind of strange, any help is appreciated Thanks Edited February 10, 2014 by tommywij Link to comment Share on other sites More sharing options...
justsomeguy Posted February 10, 2014 Share Posted February 10, 2014 If that if statement is not printing anything, then the condition it is checking for is not true. Trace the code back. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now