doxn43207 2017-06-24 11:12
浏览 74

我想创建一个简单的登录门户,但有一些问题

I created a simple login portal but there are some issues and I tried several solutions.

This is my login.php file.

<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
    <link rel="short icon" href="sopraicon.ico">
<link rel="stylesheet" href="login.css">
 <body>
<form method="POST" action="process.php" >
<img src="soprasteria.png" alt="sopra steria" width="20%" align="center"> 

<img src="share.png" alt="share" id="img1" align="right">
       <a href="">  <img src="search.png" id="img1" align="right"></a>
 <input type="text" class="search" name="search" placeholder="Search.."><br>
 <br> <div class="sidediv"></div>
 <p class="data">Sign in to Sopra Steria</p><br>
  <h3 class="h3">User Login</h3>
 <br><img src="Login.jpg" alt="login iamge" height="150px" width="170px" 
  align="left" style="padding-left:160px"><br>&emsp;&emsp;<b>Username:</b>
 <br>&emsp;&emsp;<input type="text" placeholder="User Name" name="username" 
  required id="text">
 <br>&emsp;&emsp;<b>Password:</b><br>&emsp;&emsp;<input type="password" 
  placeholder="Enter Password" name="password" required id="text" min="8">
    <br>&emsp;&emsp;<button type="submit" id="logbtn" 
  name="submit">Login</button><br>
  <div class="bottomdiv"></div>

  </form>
  </body>
  </head>
  </html>

This is my process.php file

    <?php
     $username = $_POST['username'];
     $password = $_POST['password'];

     $username = stripcslashes($username);
     $password = stripcslashes($password);
      $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);
       mysql_connect("localhost","root","");
     mysql_select_db("login");
    $result = mysql_query("select * from users where username='$username' 
     and password='$password'") or die("failed to query 
     database".mysql_error());
    $row = mysql_fetch_array(result);
     if($row['username']==$username && $row['password']== $password){
    echo"login success";
   }
    else{
   echo"failed";
   }
       ?>

but I get error on WAMP server as you see in the image. Please help me.. Thank you.

Error Image

  • 写回答

4条回答 默认 最新

  • dongmibeng5885 2017-06-24 11:17
    关注

    first you get a warning telling you to abandon the mysql* function in favor of the mysqli functions.

    Then you get the error the connection to the database using the standard user and no password failed.

    connect to the database before you use mysql_real_escape_string. When no connection is made when using the escape function, php will try to connect using a default user, which most often fails.

    -- apart from that: stripslashes is a function one should not need, as the magic-quotes it tries to eleminate was removed from php years ago. Now, you messup a password when it would contain en \

    And the password: it's not stored in plain text, is it?

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?