发送表单而不是显示 div

如果数据未在输入字段中输入或密码不匹配,则以下内容应输出 div,但它不会发生:


<?php

$data = $_POST;

if(isset($data['action_signup'])){

    $errors = array();

    if(trim($data['email'])==''){

        $errors[] = 'Введите email';

    }

    if(trim($data['login'])==''){

        $errors[] = 'Введите имя пользователя';

    }

    if($data['password']==''){

        $errors[] = 'Введите пароль';

    }

    if($data['enterpassword'] != $data['password']){

        $errors[] = 'Пароль введен не верно';

    }

    if(empty($errors)){

        //Все заебись

    }else{

        echo '<div class="error_div">'.array_shift($errors).'</div>';

    }

}


?>

形式:


<form action="/Register.php" method="post">

                    <div class="containerForTextRegister"><a class="register">РЕГИСТРАЦИЯ</a>

                    </div>

                    <div class="container_inputs">

                        <input class="register_input_email" name="email" placeholder="e-mail" required type="email" maxlength="40" value="<?php echo @$data['email'];?>">

                        <input class="register_input_login" name="login" placeholder="login" required maxlength="12" value="<?php echo @$data['login'];?>">

                        <input class="register_input_password" name="password" placeholder="password" required pattern="^[a-zA-Z]+$" maxlength="30">

                        <input class="register_input_enterpassword" name="enterpassword" placeholder="enter password" required pattern="^[a-zA-Z]+$" maxlength="30">

                        <div class="buttons_container">

                        <button class="button_entrance"><a class="text_button_entrance">войти</a></button>

                            <button class="button_register"><a class="text_button_register" name="action_signup">регистрация</a></button>

                            

                        </div>

                    </div>

                    </form>

应该会出现一个 div 窗口,但数据刚刚发送,仅此而已。帮助,我将非常感激



慕莱坞森
浏览 74回答 1
1回答

慕尼黑的夜晚无繁华

您必须将 html 代码更改<button class="button_register"><a class="text_button_register" name="action_signup">регистрация</a></button> 为或者 if(isset($data['action_signup']))到if(isset($data['email']))喜欢<?php$data = $_POST;if(isset($data['email'])){&nbsp; &nbsp; $errors = array();&nbsp; &nbsp; if(trim($data['email'])==''){&nbsp; &nbsp; &nbsp; &nbsp; $errors[] = 'Введите email';&nbsp; &nbsp; }&nbsp; &nbsp; if(trim($data['login'])==''){&nbsp; &nbsp; &nbsp; &nbsp; $errors[] = 'Введите имя пользователя';&nbsp; &nbsp; }&nbsp; &nbsp; if($data['password']==''){&nbsp; &nbsp; &nbsp; &nbsp; $errors[] = 'Введите пароль';&nbsp; &nbsp; }&nbsp; &nbsp; if($data['enterpassword'] != $data['password']){&nbsp; &nbsp; &nbsp; &nbsp; $errors[] = 'Пароль введен не верно';&nbsp; &nbsp; }&nbsp; &nbsp; if(empty($errors)){&nbsp; &nbsp; &nbsp; &nbsp; //Все заебись&nbsp; &nbsp; }else{&nbsp; &nbsp; &nbsp; &nbsp; echo '<div class="error_div">'.array_shift($errors).'</div>';&nbsp; &nbsp; }}?>
打开App,查看更多内容
随时随地看视频慕课网APP