Link to home
Start Free TrialLog in
Avatar of wantabe2
wantabe2Flag for United States of America

asked on

PHP Errors

In the code below, how can edit it so if the wr5 field is empty, it will not give ANY errors when the submit button is clicked?
if (empty($_POST['wr5'])) {
		$errors[] = 'Do not forget to enter who is responsible for sent date change.';
	} else {
		$wr5 = $_POST['wr5'];
		}
		
if (empty($errors)) {

Open in new window

Avatar of russianryebread
russianryebread
Flag of United States of America image

I'm assuming that you want to clear the entire error array if the wr5 variable from POST doesn't have a value...  If you are trying to do that you can simply unset the array like this:


if (empty($_POST['wr5'])) {
	unset($errors)
} else {
	$wr5 = $_POST['wr5'];
}
		
if (empty($errors)) {

Open in new window

Avatar of wantabe2

ASKER

If I do that I get the undefined variable error in php
ASKER CERTIFIED SOLUTION
Avatar of russianryebread
russianryebread
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial