lundi 5 octobre 2015

mysql_num_rows() error when processing script

I am adding a custom validation page to a WordPress Website I am working on.

Here is how the steps work to get a better understanding of the functional need.

  1. visitor comes to the site and trys to sign up
  2. visitor arrives to membership verification (this page will be a simple form with 3 fields that the user must enter their information as it appears on their membership card number.)
  3. If incorrect info is provided the visitor receives an error message. If they enter successful information they will be redirected to the actual registration page of the WordPress website.

The issue.

I have built all my forms and everything is working except the validation process. Here is the script I am using

<?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://ift.tt/1L1Y277"); // 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
}
}
?>

I am getting an error when I enter the information and select the submit button.

The website URL in question is http://ift.tt/1L1Y4fu

I am turing to the gurus that are within this site in hopes that you can shine some light on this issue.

Thank you all for your assistance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire