Answer the question
In order to leave comments, you need to log in
How to display error handling function $erros = array(); in Alert?
Good day to all.
I have code:
if(isset($_POST[send_reg]))
{
$check_isset_login = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` LIKE '".$_POST[login]."'"));
$erros = array();
if($check_isset_login > 0){array_push($erros, 'Login is busy');}
if(empty($_POST[login])){array_push($erros, 'Неверный логин');}
if(empty($_POST[password])){array_push($erros, 'Password is not filled');}
if(empty($_POST[repassword])){array_push($erros, 'Re-Password is not filled');}
if(empty($_POST[email])){array_push($erros, 'Email is not filled');}
if(!preg_match("/[a-zA-Z]/",$_POST[login])){array_push($erros, 'login entered incorrectly');}
if($_POST[password] != $_POST[repassword]){array_push($erros, 'Passwords do not match');}
if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST[email])){array_push($erros, 'EMail entered incorrectly');}
if ($erros === Array())
Answer the question
In order to leave comments, you need to log in
You have somewhere print_r() или var_dump()
, so you have an array entered.
If you want to display this array in js via alert, then you can do this.
//php код
$erros = implode(','$erros);
//js код
var obj = '<?=$erros;?>';
var arr = obj.split(',');
alert( 'Ваши ошибки ' + obj);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question