doutui7955 2013-11-06 15:00
浏览 47

php系统登录webmatrix

I am no expert and I am trying to do a simple login system for a website using php 5.4.9 in Microsoft's webmatrix . I seem to have done the connect.php file correctly . but there is something wrong with what is inside the second IF instruction in this login.php file, the database is connected and selected correctly but when I login in with a valid infos from my database table "Tmembers", the prog jumps to "you r not a member, please sign in" when it should say "you have successfully logged in", here is the code please help me out :

<?php

session_start();
$user = $_POST['user'];
$pwd = $_POST['pwd'];
include "connect.php";


if ($user && $pwd){

// infos provided
$queryget=mysql_query("SELECT * FROM Tmembers WHERE user='$user' AND pwd='$pwd'");
$numrows=mysql_num_rows("$queryget");

     if ($numrows !=0){
                        $_SESSION['user'] =$user;
                        echo "you have successfully logged in .";
                      }

     else echo "you r not a member, please sign in  ";
                   }

                    else{
                            echo "you didn't enter any entries !!!";
                            include "connect.php";
                         }
?>
  • 写回答

1条回答 默认 最新

  • doutuanxiao4619 2013-11-06 15:16
    关注

    You are passing the variable $queryget as a string to mysql_num_rows().

    See mysql_num_rows() in the PHP manual reference.

    Where you have

    $numrows=mysql_num_rows("$queryget");
    

    must be

    $numrows=mysql_num_rows($queryget);
    

    or the $numrows will always evaluate to false in the if.

    VERY IMPORTANT

    Remember that mysql_* functions are deprecated !

    This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

    Before you continue, choose one of them and replace all the mysql_* functions in your code.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度