Forum Moderators: coopster

Message Too Old, No Replies

appending variables

adding to the begining of a variable

         

WhosAWhata

4:26 am on Jan 27, 2004 (gmt 0)

10+ Year Member



i'm trying to add error messages together at the end of a script... is this the proper way to do it?

} else { $errormessage = "ERROR: Password can only be alphanumeric.<br>" . $errormessage; }
} else { $errormessage = "ERROR: Username can only be alphanumeric.<br>" . $errormessage; }
} else { $errormessage = "ERROR: Passwords do not match.<br>" . $errormessage; }
} else { $errormessage = "ERROR: Please fill in all required fields.<br>" . $errormessage; }

if all of the statements were false, it should save $errormessage = "ERROR: Password can only be alphanumeric.<br>ERROR: Username can only be alphanumeric.<br>ERROR: Passwords do not match.<br>ERROR: Please fill in all required fields.<br>"

as always, i'm open to suggestions on how to make this script more efficient...
THANKS

seomike2003

6:10 am on Jan 27, 2004 (gmt 0)



try using the
if(!some numeric check){
$errormessage="what ever you want it to say\n";
}
if(!condition){
$errormessage="what ever you want it to say\n";
}

//This will print it out to the screen
$errormessage=nl2br($errormessage);
echo $errormessage;

dcrombie

12:00 pm on Jan 27, 2004 (gmt 0)



$errors = array();
if ($condition1) $errors[] = "Error Message 1";
if ($condition2) $errors[] = "Error Message 2";
if ($condition3) $errors[] = "Error Message 3";

if ($errors) {
echo "<P>" . implode ("<br>\n", $errors) . "</P>";
} else {
# no errors
}