Can anyone help me figure out what is wrong with this code?

后端 未结 4 815
别跟我提以往
别跟我提以往 2021-01-24 22:24


        
4条回答
  •  星月不相逢
    2021-01-24 23:20

    These lines cause the "undefined index" warnings.

    $username = $_POST['user_name'];
    $password = $_POST['password'];
    $type = $_POST['user_type'];
    

    When you submit a form to this script, $_POST is an array containing all the form elements. In your case the user_name, password and user_type form elements did not exist, or you did not submit a form. Thus, the array elements do not exist. When you try to read from a nonexistant array element, you get the "Undefined Index" notice.

    The other warning is caused by this line:

    $count = mysql_numrows($info);
    

    You're passing $info, an array, to mysql_numrows. You should be passing it a result resource from a mysql_query. You should be passing $data to mysql_numrows.

提交回复
热议问题