I wonder if someone can help. I am trying to update my scripts from PHP5 TO PHP7. As I know php7 has done away with connect to mysql. I have been on w3schools and I have tried to do my code the way they give the example but still not working.
I have got an admin login script which goes like this
admin_login.php
[embed=425,349]<?php
session_start();
if (isset($_SESSION[“manager”])) {
header(“location: index.php”);
exit();
}
?>
index.php
[embed=425,349]<?php
session_start();
if (!isset($_SESSION[“manager”])) {
header(“location: admin_login.php”);
exit();
}
// Be sure to check that this manager SESSION value is in fact in the database
$managerID = preg_replace(’#[^0-9]#i’, ‘’, $_SESSION[“id”]); // filter everything but numbers and letters
$manager = preg_replace(’#[^A-Za-z0-9]#i’, ‘’, $_SESSION[“manager”]); // filter everything but numbers and letters
$password = preg_replace(’#[^A-Za-z0-9]#i’, ‘’, $_SESSION[“password”]); // filter everything but numbers and letters
// Run mySQL query to be sure that this person is an admin and that their password session var equals the database information
// Connect to the MySQL database
$servername = “localhost”;
$username = “username”;
$password = “password”;
$dbname = “myDB”;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = mysqli_query(“SELECT * FROM admin WHERE id=’$managerID’ AND username=’$manager’ AND password=’$password’ LIMIT 1”); // query the person
// ------- MAKE SURE PERSON EXISTS IN DATABASE ---------
$existCount = mysqli_num_rows($sql); // count the row nums
if ($existCount == 0) { // evaluate the count
echo “Your login session data is not on record in the database.”;
exit();
}
?>[/embed]
I was wondering if someone could tell me what i am doing wrong. The code is suppose to go through the admin_login.php and then after checking the login details give me a connection to index.php. but it is giving me this That information is incorrect, try again Click Here.
many thanks, Gary