我尝试创建函数,使其易于在function_html.php中使用输入文本
function form_input($label, $name, $type="text", $class="", $placeholder="", $attr=""){
echo'<div class="form-group">
<label for="'.$name.'">'.$label.'</label>
<input type="'.$type.'" name="'.$name.'" id="'.$name.'" class="'.$class.'" placeholder="'.$placeholder.'" '.$attr.'>
</div>';
}
然后我创建一个调用login_view.php中的form_input函数的表单
<form id="register-form" action="<?= BASE_PATH ?>/login/register-submit" method="post" role="form" style="display: none;">
<?php
if(isset($data['msg'])){
if(is_array($data['msg'])){
?>
<div class="alert alert-danger">
<ul>
<?php
foreach($data['msg'] as $error){
echo "<li>$error</li>";
}
?>
</ul>
</div>
<?php
}else{
echo "<div class='alert alert-success'>$data[msg]</div>";
}
}
echo "
<label for='username'>Username</label>
<div class='form-group input-group'>
<span class='input-group-addon'>@</span>
<input type='text' name='username' id='usernamer' class='form-control' placeholder='' required data-error='Username 6-8 a-z'>
</div>";
form_input("Password", "passwordr", "password", "form-control", "", "required data-error='Password can't be null");
form_input("Re-Password", "passwordr2", "password", "form-control", "", "required data-error='Password can't be null");
form_input("Email", "email", "email", "form-control", "", "required data-error='Email can't be null");
form_input("First Name", "fname", "text", "form-control", "", "required data-error='First Name 2-10 a-z");
form_input("Last Name", "lname", "text", "form-control", "", "required data-error='Last Name 2-10 a-z");
?>
</form>
但是Last Name
字段消失了
答案 0 :(得分:0)
form_input("Password", "passwordr", "password", "form-control", "", "required data-error='Password can't be null'");
form_input("Re-Password", "passwordr2", "password", "form-control", "", "required data-error='Password can't be null'");
form_input("Email", "email", "email", "form-control", "", "required data-error='Email can't be null'");
form_input("First Name", "fname", "text", "form-control", "", "required data-error='First Name 2-10 a-z'");
form_input("Last Name", "lname", "text", "form-control", "", "required data-error='First Name 2-10 a-z'");
用此代码替换您的代码。您在'
required data-error