douziqian2871 2014-03-11 21:51
浏览 152
已采纳

需要一个用户小编辑的登录用户名和密码

Firstly, l am very new to creating html and php codes in websites, so if this may seem a trivial question to some on here please appreciate that l require a bit of help. Thanks

I have created a login username and password form for just one user (html form) to work in conjunction to a .php code, it works perfectly.

Current:

  1. It will not allow the form to submit if either username and/or password fileds are blank.
  2. incorrect username and/or password displays the echo ("incorrect"); text on the www.......com/login.php page.
  3. When both username and password filed are entered correctly it redirects to the required page.

EDIT WANTED:

  1. Instead of the displaying the echo ("incorrect"); text on the www.......com/login.php page. I want "incorrect" to to be displayed underneath or within the html form. This saves going back to the original page each time to redo the entries.

Thank you.

HTML FORM:

  <fieldset>

        <legend>Login</legend>

        <label for="username" >UserName: </label>
        <input type="text" id="username" name="username" required="true" />

        <label for="pass" >Password:</label>
        <input type="password" id="pass" name="pass" required="true"/>

        <input type="submit" name="Submit" value="Submit" />
         <include'login.php'/>
     </fieldset>

</form>

login.php

<?php

       if(($_POST['username'] == "user1") && ($_POST['pass'] == "pass1"))

    { 

     header("Location:http://www.yahoo.com");

    }


    else


    {
      echo ("incorrect");

    }


    ?>
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 怎么将vs中的程序同步到sql中的表中
      • ¥15 用flask框架接收前端上传的文本文件后怎么读取该文件
      • ¥15 有没有嵌入式ubuntu的朋友
      • ¥50 diddler Burp Suite
      • ¥20 关于UE5.1的问题,求专家解答!
      • ¥30 关于#爬虫#的问题:百度为您找到相关结果约100,000,000个 但只展现70页 有没有可能提取出来全部的搜索结果
      • ¥40 IIS部署API,弄了几天没弄出来,希望带佬远程帮我弄一下,有偿
      • ¥15 关于#c##的问题:winform中利用delegate更新ui的顺序错误
      • ¥15 qt5.6.1读取oracle8中文数据乱码
      • ¥15 matlab支持向量机预测部分遇到了问题