处理脚本时出现mysql_num_rows()错误

时间:2015-10-05 15:27:22

标签: php mysql wordpress forms

我正在为我正在处理的WordPress网站添加自定义验证页面。

以下是这些步骤如何帮助您更好地了解功能需求。

  1. 访问者访问该网站并尝试注册
  2. 访客到达会员身份验证(此页面将是一个简单的表单,其中包含3个字段,用户必须在其会员卡号上显示其信息。)
  3. 如果提供的信息不正确,则访问者会收到错误消息。如果他们输入成功的信息,他们将被重定向到WordPress网站的实际注册页面。
  4. 问题。

    我已经构建了所有表单,除验证过程外,一切正常。这是我正在使用的脚本

    <?php
    $error=''; // Variable To Store Error Message
    if (isset($_POST['submit'])) {
    if (empty($_POST['int_no']) || empty($_POST['firstnames']) || empty($_POST['surname'])) {
    $error = "It appears that you have forgotten to fill out one of the form fields. Please fill out all requested information and try again.";
    }
    else
    {
    // Define $int_no $firstnames and $surname
    $int_no=$_POST['int_no'];
    $firstnames=$_POST['firstnames'];
    $surname=$_POST['surname'];
    // Establishing Connection with Server by passing server_name, user_id and password as a parameter
    $connection = mysql_connect("localhost", "username", "password");
    // To protect MySQL injection for Security purpose
    $int_no = stripslashes($int_no);
    $firstnames = stripslashes($firstnames);
    $surname = stripslashes($surname);
    $int_no = mysql_real_escape_string($int_no);
    $firstnames = mysql_real_escape_string($firstnames);
    $surname = mysql_real_escape_string($surname);
    // Selecting Database
    $db = mysql_select_db("IUEC-MEMBERS", $connection);
    // SQL query to fetch information of registered Union Members and finds if there is a match.
    $query = mysql_query("select * from login where surname='$surname' AND firstnames='$firstnames' AND int_no='$int_no'", $connection);
    $rows = mysql_num_rows($query);
    if ($rows == 1) {
    $_SESSION['login_user']=$int_no; // Initializing Session
    header("location: http://iuec50.info/preview/online-membership-registration/"); // Redirecting To Other Page
    } else {
    $error = "We were not able to verify the information you provided. Please ensure you are entering your information as it appears on your International Card. If you continue to have issues please contact your Local.";
    }
    mysql_close($connection); // Closing Connection
    }
    }
    ?>
    

    输入信息并选择提交按钮时出现错误。

    相关网站网址为http://iuec50.info/preview/member-sign-up/

    我想到这个网站内的大师,希望你能对这个问题有所了解。

    谢谢大家的帮助。

0 个答案:

没有答案