注册表单功能与搜索表单

时间:2016-05-10 06:31:08

标签: php html forms

我的php中的表单出现了问题,我有一个搜索表单和一个注册表单,但每当我包含header.php,其中搜索表单与注册表单在同一页面时,注册表单需要搜索文本框也应填写....请帮助...提前感谢...这里是搜索表单的位置:

<?php //header.php

echo "<header class='top' role='header'>
     <div class='container head' style='padding:0 !important;'>
        <nav class='navbar navbar-default' style='margin-bottom:0px;'>
            <div class='container-fluid' style='background-color:white;'>

                <div class='navbar-header'>
                    <button type='button' class='navbar-toggle collapsed'           data-toggle='collapse' data-target='#bs-example-navbar-collapse-1' aria-expanded='false'>
                        <span class='sr-only'>
                            Toggle navigation
                        </span>
                        <span class='icon-bar'>
                        </span>
                        <span class='icon-bar'>
                        </span>
                        <span class='icon-bar'>
                        </span>
                    </button>

                    <a class='navbar-brand' href=''>
                        <img id='logo' class='logo' name='logo' src='../images/euLogo.png' />
                    </a>
                </div>

                <div class='collapse navbar-collapse' id='bs-example-navbar-collapse-1'>                        
                    <form class='navbar-form navbar-left frm-search' role='search'>
                        <div class='form-group'>
                            <input type='text' class='form-control' placeholder='Search' />
                        </div>

                        <button type='submit' class='btn btn-info'>
                            <span class='glyphicon glyphicon-search'>
                            </span>
                        </button>
                    </form>

                    <ul class='nav navbar-nav navbar-right'>
                        <li>
                            <a href=''><img id='btn-credits' class='btn-credits' name='btn-credits' src='../images/piggybank.png' />
                            </a>
                        </li>
                        <li>
                            <a href='https://www.facebook.com/uniteenglish/?fref=ts'>
                                <img id='btn-FBLike' name='btn-FBLike' class='btn-FBLike' src='../images/like.png' />
                            </a>
                        </li>
                        <li class='dropdown'>
                            <a href='' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>
                                Welcome 
                                <label id='user-name' name='user-name' class='user-name'> 
                                </label> 
                                <span class='caret'>
                                </span>
                            </a>

                            <ul class='dropdown-menu'>
                                <li>
                                    <a href=''>
                                        My Account
                                    </a>
                                </li>
                                <li>
                                    <a href=''>
                                        My Credits
                                    </a>
                                </li>
                                <li>
                                    <a href=''>
                                        Something else here
                                    </a>
                                </li>
                                <li role='separator' class='divider'>
                                </li>
                                <li>
                                    <a href=''>
                                        Separated link
                                    </a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </div>
</header>";
?>

还有register.php:

<?php 
echo "<div class='container'>

<br/>

    <form action='registeruser.php' id='frm-register' name='frm-register' class='frm-register' method='POST'>

        <label>

            User name: 

        </label> 

        <input type='text' id='username' class='form-control frm' name='username' />

        <span class='errorMessage'>

        </span>

        <br/>

        <label>

            Email: 

        </label> 

        <input type='email' id='email' class='form-control frm' name='email' />

        <span class='errorMessage'>

        </span>

        <br/>

        <label>

            Confirm Email: 

        </label> 

        <input type='email' id='re_email' class='form-control frm' name='re_email' />

        <span class='errorMessage'>

        </span>

        <br/>

        <label>

            Password: 

        </label> 

        <input type='password' id='password' class='form-control frm' name='password' />

        <span class='errorMessage'>

        </span>

        <br/>

        <label>

            Confirm Password: 

        </label> 

        <input type='password' id='re_password' class='form-control frm' name='re_password' />

        <span class='errorMessage'>

        </span>

        <br/>

        <label>

            I am a: 

        </label> 

        <select id='iam' class='form-control frm' name='iam'>

            <option value='Teacher'>

                Teacher

            </option>

            <option value='Student'>

                Student

            </option>

            <option value='Parent'>

                Parent

            </option>

        </select>

        <br/>

        <label> 

            <input type='checkbox' id='agree' name='agree' class='check' value='I agree to terms and conditions and privacy policy.' /> 

            I agree to terms and conditions and privacy policy.

        </label>

        <br/>

        <br/>

        <label>

            Registration Type: 

        </label> 

        <input type='text' id='role' class='form-control frm' name='role' value='Member' readonly />

        <br/>

        <input type='submit' id='btn-register' class='form-control btn btn-danger frm' name='btn-register' value='Register Now' />

        <br/>

        <br/>

    </form>

</div>";

?>

1 个答案:

答案 0 :(得分:0)

我认为您的问题是您没有为搜索表单分配minimun属性,并且寄存器正在使其成为必需。应该像这样修复:

<form class='navbar-form navbar-left frm-search' role='search' name='search' method="post" action="yourfile.php">
  <div class='form-group'>
    <input type='text' class='form-control' placeholder='Search' />
  </div>
  <button type='submit' class='btn btn-info'>
    <span class='glyphicon glyphicon-search'></span>
  </button>
</form>  

这是一个关于身份识别的问题,因为注册表认为搜索属于它。

有关详细信息和良好做法,我建议您this post

希望这会对你有所帮助。