Jump to content

need help strange error on php form handling


tommywij
 Share

Recommended Posts

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 by tommywij
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...