douzhuoxia0587 2015-09-25 15:23
浏览 7
已采纳

基于使用的凭据的基本用户重定向[关闭]

I'm setting up a plain HTML/PHP(to perform include()) website for demo purposes strictly. I'd like to make a functional login page that redirects the user based on the credentials used.

For example: If the user/pass combination used was "editor" and "123456" respectively, then he will be redirected to /editor.html. The same for "admin" and "user" members...

Certainly I already have the basic login layout in HTML, but how can I make it functional that way? How could I achieve this effectively?

Thank you very much for your time, Regards

Html code

<div id="pane-login" class="panel-body active">
      <div class="form-group">
        <div class="inputer">
          <div class="input-wrapper">
            <input type="text" class="form-control" placeholder="User">
          </div>
        </div>
      </div>
      <!--.form-group-->

      <div class="form-group">
        <div class="inputer">
          <div class="input-wrapper">
            <input type="password" class="form-control" placeholder="Pass">
          </div>
        </div>
      </div>
      <!--.form-group-->

      <div class="form-buttons clearfix">
        <label class="pull-left">
          <input type="checkbox" name="remember" value="1">
          Remember</label>
        <button type="submit" onclick="location.href='index.php';" class="btn btn-success pull-right">Enter</button>
      </div>
      <!--.form-buttons-->
    </div>
  • 写回答

2条回答 默认 最新

  • dongyi1921 2015-09-25 15:46
    关注

    Okay so first of all, your form isn't actually a form here.

    Prepend to the inputs:

     <form name="formname" method="POST" action="yourphpfile.php">
    

    and end with a

     </form>
    

    Add a "name" value to each of the inputs Remove the onClick from your submit Button.

    In your php file, do the following:

    $username = $_POST["firstinputname"]
    $password = $_POST["password"]
    

    Evaluate the login info and do a switch case in case login is correct;

    switch($username)
    {
        case "editor":
              header('Location: /yourlocation.php');
              break;
    
        case "another":
              header('Location: /anotherlocation.php');
              break;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?