/    Sign up×
Community /Pin to ProfileBookmark

Why Echoing Row Data From Mysql Tbls Fail ?

Php Folks,

Below is a membership php script I am building.

config.php

functions_list.php

eror_reporting.php

site_details.php

conn.php

login_check.php

account_header.php

login_v1.php

sessions.php

home_v1.php

Now, when you login, you are taken to home_v1.php that displays your details from tbls: users, personal_details, home_contact_details, business_contact_details.

Problem is last 2 tables’ data do not show-up on the homepage. Get no mysql error either! What a nuisancical mystery! Been going round in circles for nearly a wk now! I give-up! Only bothering you guys as a last resort!

What do you reckon the problem is ? Maybe a bug perhaps with php ?

The concerned tables do have data! See for yourselves.

The 2 tbls data is below as attachment is failing to upload.

Do not want to be burdening you guys with all files and so only provided relevant ones for you to easily check in your wamp/xamp.

NOTE:

On the comments on home_v1.php, note the “//NOT WORKING”. This is where I am having trouble as data from the 2 tbls (home_contact_details, business_contact_details) are not getting grabbed and displayed.

You really need to check login_v1.php, sessions.php and home_v1.php. Other files provided for your convenience.

I wonder if I messed things up on the sessions variables. In that case you may check login_v1.php, sessions.php and ofcourse home_v1.php.

test.sql

[code]

— phpMyAdmin SQL Dump
— version 4.8.3
— https://www.phpmyadmin.net/

— Host: 127.0.0.1
— Generation Time: Nov 20, 2018 at 08:38 PM
— Server version: 10.1.36-MariaDB
— PHP Version: 7.2.11

SET SQL_MODE = “NO_AUTO_VALUE_ON_ZERO”;
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = “+00:00″;

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;


— Database: `test`

— ——————————————————–


— Table structure for table `business_contact_details`

CREATE TABLE `business_contact_details` (
  `id` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `date_&_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `business_blog` varchar(255) NOT NULL,
  `business_name` varchar(50) NOT NULL,
  `business_email` varchar(50) NOT NULL,
  `business_mobile` int(50) DEFAULT NULL,
  `business_land_line_phone` int(50) DEFAULT NULL,
  `business_fax` int(50) DEFAULT NULL,
  `business_zip` varchar(50) NOT NULL,
  `business_town` varchar(50) DEFAULT NULL,
  `business_neighbourhood` varchar(50) DEFAULT NULL,
  `business_borough` varchar(50) DEFAULT NULL,
  `business_city` varchar(50) DEFAULT NULL,
  `business_county` varchar(50) DEFAULT NULL,
  `business_district` varchar(50) DEFAULT NULL,
  `business_region` varchar(50) DEFAULT NULL,
  `business_state` varchar(50) DEFAULT NULL,
  `business_country` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


— Dumping data for table `business_contact_details`

INSERT INTO `business_contact_details` (`id`, `username`, `date_&_time`, `business_blog`, `business_name`, `business_email`, `business_mobile`, `business_land_line_phone`, `business_fax`, `business_zip`, `business_town`, `business_neighbourhood`, `business_borough`, `business_city`, `business_county`, `business_district`, `business_region`, `business_state`, `business_country`) VALUES
(1, ‘admin123’, ‘2018-11-20 19:16:40’, ‘blogs.yahoo.com’, ‘loudwoman’, ‘[email protected]’, 1789504580, 286980665, 286980665, ‘nq1’, ‘Surrey’, ‘Surrey’, ‘Surrey’, ‘Surrey’, ‘Surrey’, ‘Surrey’, ‘Surrey’, ‘England’, ‘UK’),
(3, ‘spaceman’, ‘2018-11-20 19:16:40’, ‘spaceman.gmail.com’, ‘spacey’, ‘[email protected]’, 234567, 12345667, 4353555, ‘fv5’, ‘redmond’, ‘redmond’, ‘redmond’, ‘newland’, ‘newland’, ‘newland’, ‘newland’, ‘Uttah’, ‘USA’);

— ——————————————————–


— Table structure for table `home_contact_details`

CREATE TABLE `home_contact_details` (
  `id` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `date_&_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `personal_blog` varchar(255) DEFAULT NULL,
  `personal_email` varchar(50) NOT NULL,
  `personal_mobile` int(50) DEFAULT NULL,
  `home_land_line_phone` int(50) DEFAULT NULL,
  `home_fax` int(11) DEFAULT NULL,
  `home_zip` varchar(50) DEFAULT NULL,
  `home_town` varchar(50) DEFAULT NULL,
  `home_neighbourhood` varchar(50) DEFAULT NULL,
  `home_borough` varchar(50) DEFAULT NULL,
  `home_city` varchar(50) DEFAULT NULL,
  `home_county` varchar(50) DEFAULT NULL,
  `home_district` varchar(50) DEFAULT NULL,
  `home_region` varchar(50) DEFAULT NULL,
  `home_state` varchar(50) DEFAULT NULL,
  `home_country` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


— Dumping data for table `home_contact_details`

INSERT INTO `home_contact_details` (`id`, `username`, `date_&_time`, `personal_blog`, `personal_email`, `personal_mobile`, `home_land_line_phone`, `home_fax`, `home_zip`, `home_town`, `home_neighbourhood`, `home_borough`, `home_city`, `home_county`, `home_district`, `home_region`, `home_state`, `home_country`) VALUES
(1, ‘admin123’, ‘2018-11-20 19:13:23’, ‘blogs.yahoo.com’, ‘[email protected]’, 123456, 123456, 123456, ‘Wc1’, ‘Birmingham’, NULL, ‘Birmingham’, ‘Birmingham’, ‘Birmingham’, NULL, ‘Birmingham’, ‘Carolina’, ‘United States’),
(3, ‘wonderwoman’, ‘2018-11-20 19:13:23’, ‘blogs.gmail.com’, ‘[email protected]’, 0, NULL, 0, NULL, ‘California’, NULL, ‘California’, ‘California’, ‘California’, NULL, ‘California’, ‘N/A’, ‘USA’);

— ——————————————————–


— Table structure for table `users`

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `date_&_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `account_activation_code` varchar(255) NOT NULL,
  `account_activation_status` int(2) NOT NULL,
  `id_video_verification_status` int(2) NOT NULL,
  `id_verification_video_file_url` varchar(255) DEFAULT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `primary_domain` varchar(255) NOT NULL,
  `primary_website_email` varchar(255) NOT NULL,
  `sponsor_username` varchar(255) NOT NULL,
  `recruits_number` int(10) NOT NULL,
  `registering_country` varchar(255) NOT NULL,
  `registering_ip` varchar(255) DEFAULT NULL,
  `registering_browser` varchar(255) DEFAULT NULL,
  `registering_os` varchar(255) DEFAULT NULL,
  `registering_isp` varchar(255) DEFAULT NULL,
  `age_range` varchar(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


— Dumping data for table `users`

INSERT INTO `users` (`id`, `date_&_time`, `account_activation_code`, `account_activation_status`, `id_video_verification_status`, `id_verification_video_file_url`, `username`, `password`, `primary_domain`, `primary_website_email`, `sponsor_username`, `recruits_number`, `registering_country`, `registering_ip`, `registering_browser`, `registering_os`, `registering_isp`, `age_range`) VALUES
(0, ‘2018-11-20 19:22:36’, ‘0300bf1542f6e6261f606542c2320bbb9efaf359’, 1, 1, NULL, ‘admin123’, ‘$2y$10$tM9gMGQ6Z6wNxJ/t8neIKOtQcRk1WwQIEBqxo55SgUwv710nfj0m2’, ‘gmail.com’, ‘[email protected]’, ‘admin123’, 1, ”, NULL, NULL, ”, ”, ”),
(1, ‘2018-11-20 19:21:34’, ‘1300bf1542f6e6261f606542c2320bbb9efaf360’, 1, 1, NULL, ‘admin1234’, ‘$2y$10$tM9gMGQ6Z6wNxJ/t8neIKOtQcRk1WwQIEBqxo55SgUwv710nfj0m2’, ‘yahooinvader.co.uk’, ‘[email protected]’, ‘wonderman’, 0, ‘USA’, NULL, NULL, ”, ”, ’41-50′),
(7, ‘2018-11-20 19:21:35’, ‘b06d8f2dbdc9c99e032fdffb44a3e7e49766c267’, 0, 0, NULL, ‘loudmouth’, ‘$2y$10$MIcXW3Vx6HHSEzr.bsNN.eL336VT32un6RhiIFfVhDB8BfGJrT2vu’, ‘fnulll.com’, ‘[email protected]’, ‘admin123’, 1, ‘Germany’, NULL, NULL, ”, ”, ’71-75′);


— Indexes for dumped tables


— Indexes for table `business_contact_details`

ALTER TABLE `business_contact_details`
  ADD PRIMARY KEY (`id`);


— Indexes for table `home_contact_details`

ALTER TABLE `home_contact_details`
  ADD PRIMARY KEY (`id`);


— Indexes for table `users`

ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `usernames` (`username`),
  ADD UNIQUE KEY `emails` (`primary_website_email`),
  ADD UNIQUE KEY `primary_website_domain` (`primary_domain`);


— AUTO_INCREMENT for dumped tables


— AUTO_INCREMENT for table `business_contact_details`

ALTER TABLE `business_contact_details`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;


— AUTO_INCREMENT for table `home_contact_details`

ALTER TABLE `home_contact_details`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;


— AUTO_INCREMENT for table `users`

ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

[/code]

1.

config.php

[code]

<?php 

//Include both FUNCTIONS and PHP Files. 

//Required PHP Files. 
include ‘error_reporting.php’; 
include ‘site_details.php’; 
include ‘conn.php’; 

//Required FUNCTIONS Files. 
include ‘functions_list.php’; 

?> 

[/code]

2.

functions_list.php

[code]

<?php 

//All FUNCTIONS List File. 
include ‘login_check.php’; 

?> 

[/code]

3.

error_reporting.php

[code]

<?php 

//ERROR REPORTING CODES. 
declare(strict_types=1); 
ini_set(‘display_errors’, ‘1’); 
ini_set(‘display_startup_errors’, ‘1’); 
error_reporting(E_ALL); 
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); 

?> 

[/code]

4.

site_details.php

[code]

<?php 

$site_name = “Idea Experimenter”; 
$social_network_name = “Idea Experimenter”; 

$site_domain = “test.com”; 
$social_network_domain = “test.com”; 

$site_admin_username = “admin123”; 
$site_admin_email = “[email protected]”; 

$social_network_admin_username = “admin123”; 
$social_network_admin_email = “[email protected]”; 

$server_time = “California,USA”; 

?> 

[/code]

5.

conn.php

[code]

<?php 

//Connect to Mysql Database in this input format: “Server”, “MySql User”, “Mysql User Password”, “MySql Database Name”. 
$conn = mysqli_connect(“localhost”,”root”,””,”test”); 

if (!$conn) 

    //Error Message to show user in technical/development mode to see errors.
    die(“Database Error : ” . mysqli_error($conn)); 
    
    //Error Message to show User in Layman’s mode to see errors.
    die(“Database error.”); 
    exit(); 

?> 

[/code]

6.

login_check.php

[code]

<?php 

//login_check() FUNCTION File.
/*
Check if User is logged-in or not by checking if the session names “user” is set (isset) or not. Return “TRUE” if it is; Else “FALSE”.
*/

//Have to initiate the “session_start” global variable, regardless of whether User is logged-in or not, in order to deal with session stuffs in php.

/* Replacing following chunk:

if(!session_start())
{
    session_start();
}

*/

//Replacing to this instead:
if( session_status() != PHP_SESSION_ACTIVE ) session_start();

//Function for checking if User is logged-in or not.
function login_check()
{
    if(isset($_SESSION[“user”]) && !empty($_SESSION[“user”]))
    {
        //If Session “user” is set and not empty then return TRUE.
        return TRUE;
    }
    else
    {
        //If Session “User” is NOT set or if session is empty then return FALSE.
        return FALSE;
    }
}

?>

[/code]

7.

account_header.php

[code]

<?php 

//Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
if (login_check() === FALSE) 

    //Redirect User to Log-in Page immediately. 
    //header(“refresh:0 url=login.php”); 
    header(“location:login_v1.php”); 
    exit(); 

else 

    include ‘account_header_ad.php’; //Will display on all webpages inside the account. 

?> 

[/code]

8.

login_v1.php

[code]

<?php 

//Required PHP Files. 
include ‘config.php’; 
//Do not include ‘account_header.php’ here or login.php would go in a redirection loop. 

/*
//Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
if (login_check() === TRUE) 
{
    //Redirect User to Log-in Page immediately. 
    //header(“refresh:0; url=home.php”); 
    header(“location:home_v1.php?user=$user”); 
    exit(); 
}
*/

if (isset($_POST[“login_username_or_email_or_domain”]) && isset($_POST[“login_password”])) 
{
    $login_username_or_email_or_domain = trim($_POST[“login_username_or_email_or_domain”]); 
    $login_password = $_POST[“login_password”]; 
        
    //Check if User inputted Username/Email exist in db. Registered or not. 
    //Select Username or Email to check against Mysql DB if they are already registered or not.         
    if(strpos(“login_username_or_email_or_domain”,”@”)) 
    {    
        $querying_column = “website_email”; 
    } 
    elseif(strpos(“login_username_or_email_or_domain”,”.”)) 
    { 
        $querying_column = “domain”; 
    } 
    else 
    { 
        $querying_column = “username”; 
    }    
    //Make sure the users table has atleast these 3 columns: username,primary_domain and website_email due to the $querying_column variable which could hold any of these 3 values. 
    $query_1 = “SELECT id,recruits_number,sponsor_username,account_activation_status,id_video_verification_status,id_verification_video_file_url,username,password,primary_domain,primary_website_email,registering_country,registering_ip,registering_browser,registering_os,registering_isp,age_range FROM users WHERE $querying_column = ?”; 
    $stmt_1 = mysqli_prepare($conn,$query_1); 
    mysqli_stmt_bind_param($stmt_1,’s’,$login_username_or_email_or_domain); 
    mysqli_stmt_execute($stmt_1); 
    $result_1 = mysqli_stmt_bind_result($stmt_1,$db_id,$db_recruits_number,$db_sponsor_username,$db_account_activation_status,$db_id_video_verification_status,$db_id_verification_video_file_url,$db_username,$db_password,$db_primary_domain,$db_website_email,$db_registering_country,$registering_ip,$registering_browser,$registering_os,$registering_isp,$db_age_range); 
    mysqli_stmt_fetch($stmt_1); 
    mysqli_stmt_close($stmt_1); 
    //Free Result_1 Set 
    mysqli_stmt_free_result($stmt_1); 
    
    $query_2 = “SELECT title,first_name,middle_name,surname,gender,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,country_of_birth,bio FROM personal_details WHERE id = ?”; 
    $stmt_2 = mysqli_prepare($conn,$query_2); 
    mysqli_stmt_bind_param($stmt_2,’s’,$db_id); 
    mysqli_stmt_execute($stmt_2); 
    $result_1 = mysqli_stmt_bind_result($stmt_2,$db_title,$db_first_name,$db_middle_name,$db_surname,$db_gender,$db_date_of_birth,$db_skin_complexion,$db_height,$db_weight,$db_sexual_orientation,$db_religion,$db_education,$db_profession,$db_marital_status,$db_working_status,$db_country_of_birth,$db_bio); 
    mysqli_stmt_fetch($stmt_2); 
    mysqli_stmt_close($stmt_2); 
    //Free Result_2 Set 
    mysqli_stmt_free_result($stmt_2); 
    
    $query_3 = “SELECT personal_blog,personal_email,personal_mobile,home_land_line_phone,home_fax,home_zip,home_town,home_neighbourhood,home_borough,home_city,home_district,home_county,home_region,home_state,home_country FROM home_contact_details WHERE id = ?”; 
    $stmt_3 = mysqli_prepare($conn,$query_3); 
    mysqli_stmt_bind_param($stmt_3,’s’,$db_id); 
    mysqli_stmt_execute($stmt_3); 
    $result_3 = mysqli_stmt_bind_result($stmt_3,$db_persona_blog,$db_personal_email,$db_personal_mobile,$db_home_land_line_phone,$db_home_fax,$db_home_zip,$db_home_town,$db_home_neighbourhood,$db_home_borough,$db_home_city,$db_home_district,$db_home_county,$db_home_region,$db_home_state,$db_home_country);     
    mysqli_stmt_fetch($stmt_3); 
    mysqli_stmt_close($stmt_3); 
    //Free Result_3 Set 
    //mysqli_stmt_free_result($stmt_3); 
    
    $query_4 = “SELECT business_blog,business_name,business_email,business_mobile,business_land_line_phone,business_fax,business_zip,business_town,business_neighbourhood,business_borough,business_city,business_district,business_county,business_region,business_state,business_country FROM business_contact_details WHERE id = ?”; 
    $stmt_4 = mysqli_prepare($conn,$query_4); 
    mysqli_stmt_bind_param($stmt_4,’s’,$db_id); 
    mysqli_stmt_execute($stmt_4); 
    $result_3 = mysqli_stmt_bind_result($stmt_3,$db_business_blog,$db_business_name,$db_business_email,$db_business_mobile,$db_business_land_line_phone,$db_business_fax,$db_business_zip,$db_business_town,$db_business_neighbourhood,$db_business_borough,$db_business_city,$db_business_district,$db_business_county,$db_business_region,$db_business_state,$db_business_country);     
    mysqli_stmt_fetch($stmt_4); 
    mysqli_stmt_close($stmt_4); 
    //Free Result_4 Set 
    //mysqli_stmt_free_result($stmt_4); 
    
    if (!password_verify($login_password,$db_password)) 
    { 
        echo “Incorrect log-in details3<br>”; 
        exit(); 
    } 
    else 
    { 
        $user = $db_username; 
        //Session Variables associated with ‘users’ tbl.  
        $_SESSION[“user”] = $user; 
        $_SESSION[‘id’] = $db_id; 
        $_SESSION[“recruits_number”] = $db_recruits_number; 
        $_SESSION[“sponsor_username”] = $db_sponsor_username; 
        $_SESSION[“account_activation_status”] = $db_account_activation_status; 
        $_SESSION[“id_video_verification_status”] = $db_id_video_verification_status; 
        $_SESSION[“id_verification_video_file_url”] = $db_id_verification_video_file_url; 
        $_SESSION[“username”] = $db_username; 
        $_SESSION[“primary_domain”] = $db_primary_domain;         
        $_SESSION[“primary_website_email”] = $db_primary_website_email; 
        $_SESSION[“registering_country”] = $db_registering_country; 
        $_SESSION[“registering_ip”] = $db_registering_ip; 
        $_SESSION[“registering_browser”] = $db_registering_browser; 
        $_SESSION[“registering_os”] = $db_registering_os; 
        $_SESSION[“registering_isp”] = $db_registering_isp; 
        $_SESSION[“age_range”] = $db_age_range; 
        //Session Variables associated with ‘personal_details’ tbl. 
        $_SESSION[“personal_details_verified_by_recruiter”] = $db_personal_details_verified_by_recruiter; 
        $_SESSION[“passport_size_photoh_image”] = $db_passport_size_photoh_image; 
        $_SESSION[“title”] = $db_title; 
        $_SESSION[“first_name”] = $db_first_name; 
        $_SESSION[“middle_name”] = $db_middle_name; 
        $_SESSION[“surname”] = $db_surname; 
        $_SESSION[“gender”] = $db_gender; 
        $_SESSION[“age_range”] = $db_age_range; 
        $_SESSION[“date_of_birth”] = $db_date_of_birth; 
        $_SESSION[“skin_complexion”] = $db_skin_complexion; 
        $_SESSION[“height”] = $db_height; 
        $_SESSION[“weight”] = $db_weight; 
        $_SESSION[“sexual_orientation”] = $db_sexual_orientation; 
        $_SESSION[“religion”] = $db_religion; 
        $_SESSION[“education”] = $db_education; 
        $_SESSION[“profession”] = $db_profession; 
        $_SESSION[“marital_status”] = $db_marital_status; 
        $_SESSION[“working_status”] = $db_working_status; 
        $_SESSION[“country_of_birth”] = $db_country_of_birth; 
        $_SESSION[“bio”] = $db_bio; 
        //Session Variables associated with ‘home_contact_details’ tbl. 
        $_SESSION[“personal_blog”] = $db_personal_blog; 
        $_SESSION[“personal_email”] = $db_personal_email; 
        $_SESSION[“personal_mobile”] = $db_personal_mobile; 
        $_SESSION[“home_land_line_phone”] = $db_home_land_line_phone; 
        $_SESSION[“home_fax”] = $db_home_fax; 
        $_SESSION[“home_zip”] = $db_home_zip; 
        $_SESSION[“home_town”] = $db_home_town; 
        $_SESSION[“home_neighbourhood”] = $db_home_neighbourhood; 
        $_SESSION[“home_borough”] = $db_home_borough; 
        $_SESSION[“home_city”] = $db_home_city; 
        $_SESSION[“home_county”] = $db_home_county; 
        $_SESSION[“home_district”] = $db_home_district;         
        $_SESSION[“home_region”] = $db_home_region; 
        $_SESSION[“home_state”] = $db_home_state; 
        $_SESSION[“home_country”] = $db_home_country; 
        //Session Variables associated with ‘business_contact_details’ tbl. 
        $_SESSION[“business_blog”] = $db_business_blog; 
        $_SESSION[“business_name”] = $db_business_name; 
        $_SESSION[“business_email”] = $db_business_email; 
        $_SESSION[“business_mobile”] = $db_business_mobile; 
        $_SESSION[“business_land_line_phone”] = $db_business_land_line_phone; 
        $_SESSION[“business_fax”] = $db_business_fax; 
        $_SESSION[“business_zip”] = $db_business_zip; 
        $_SESSION[“business_town”] = $db_business_town; 
        $_SESSION[“business_neighbourhood”] = $db_business_neighbourhood; 
        $_SESSION[“business_borough”] = $db_business_borough; 
        $_SESSION[“business_city”] = $db_business_city; 
        $_SESSION[“business_county”] = $db_business_county; 
        $_SESSION[“business_district”] = $db_business_district; 
        $_SESSION[“business_region”] = $db_business_region; 
        $_SESSION[“business_state”] = $db_business_state; 
        $_SESSION[“business_country”] = $db_business_country; 
        
        header(“location:home_v1.php?user=$user”); 
    } 

?> 

<!DOCTYPE html> 
<html> 
<head> 
<title><?php $site_name ?> Member Login Page</title> 
    <meta charset=”utf-8″> 
    <meta name=”viewport” content=”width=device-width, initial-scale=1″> 
</head> 
<body> 

<?php 
/* 
$_GET and $_POST have two different enctype settings in the form. 
If we do not specify which one to use, the default is “plain/text”. 
With $_GET you use “application/x-www-form-urlencode” and with $_POST you use “multipart/form-data”. 
*/ 
?>

<form name = “login_form” method = “post” action=”” enctype = “multipart/form-data”> 
    <h3><?php echo “$site_name”;?> Member Login Form</h3> 
    <fieldset> 
        <label for=”login_name”>Username/Email:</label> 
        <input type=”text” name=”login_username_or_email_or_domain” id=”login_name” required [A-Za-z0-9] autocorrect=off value=””><br> 
        <label for=”login_pass”>Password:</label> 
        <input type=”password” name=”login_password” id=”login_pass” required [A-Za-z0-9] autocorrect=off value=””> 
    </fieldset> 
    <div class=”SubmitsAndHiddens”> 
        <label for=”login_remember”>Remember Log-in Details:</label> 
        <input type=”checkbox” name=”login_remember” id=”login_remember” /> 
        <br> 
        <p align=”left”><input type=”submit” class=”btn btn-default” name=”submit” value=”Log-in!”></p> 
        <br> 
        <a href=”login_password_reset.php”>Forgot your password ? Reset it here!</a> 
        <br> 
        <a href=”register.php”>Don’t yet have an account ? Register here!</a> 
    </div> 
</form> 
</body> 
</html>

[/code]

9.

sessions.php

[code]

<?php 
//$_SESSION Variables associated with ‘users’ tbl. 
$user = $_SESSION[“user”]; 
$id = $_SESSION[‘id’]; 
$sponsor_username = $_SESSION[“sponsor_username”]; 
$recruits_number = $_SESSION[“recruits_number”]; 
$account_activation_status = $_SESSION[“account_activation_status”]; 
$id_video_verification_status = $_SESSION[“id_video_verification_status”]; 
$id_verification_video_file_url = $_SESSION[“id_verification_video_file_url”]; 
$username = $_SESSION[“username”]; 
$primary_domain = $_SESSION[“primary_domain”]; 
$primary_website_email = $_SESSION[“primary_website_email”]; 
$registering_country = $_SESSION[“registering_country”]; 
$registering_ip = $_SESSION[“registering_ip”]; 
$registering_browser = $_SESSION[“registering_browser”]; 
$registering_os = $_SESSION[“registering_os”]; 
$registering_isp = $_SESSION[“registering_isp”]; 
$age_range = $_SESSION[“age_range”]; 
//$_SESSION Variables associated with ‘personal_details’ tbl. 
$personal_details_verified_by_recruiter = $_SESSION[“personal_details_verified_by_recruiter”]; 
$passport_size_photoh_image = $_SESSION[“passport_size_photoh_image”]; 
$title = $_SESSION[“title”]; 
$first_name = $_SESSION[“first_name”]; 
$middle_name = $_SESSION[“middle_name”]; 
$surname = $_SESSION[“surname”];
$gender = $_SESSION[“gender”]; 
$date_of_birth = $_SESSION[“date_of_birth”]; 
$skin_complexion = $_SESSION[“skin_complexion”]; 
$height = $_SESSION[“height”]; 
$weight = $_SESSION[“weight”]; 
$sexual_orientation = $_SESSION[“sexual_orientation”]; 
$religion = $_SESSION[“religion”]; 
$education = $_SESSION[“education”]; 
$profession = $_SESSION[“profession”]; 
$marital_status = $_SESSION[“marital_status”]; 
$working_status = $_SESSION[“working_status”]; 
$country_of_birth = $_SESSION[“country_of_birth”]; 
$bio = $_SESSION[“bio”]; 
//$_SESSION Variables associated with ‘home_contact_details’ tbl. 
$personal_blog = $_SESSION[“personal_blog”]; 
$personal_email = $_SESSION[“personal_email”]; 
$personal_mobile = $_SESSION[“personal_mobile”]; 
$home_land_line_phone = $_SESSION[“home_land_line_phone”]; 
$home_fax = $_SESSION[“home_fax”]; 
$home_zip = $_SESSION[“home_zip”]; 
$home_town = $_SESSION[“home_town”]; 
$home_neighbourhood = $_SESSION[“home_neighbourhood”]; 
$home_borough = $_SESSION[“home_borough”]; 
$home_city = $_SESSION[“home_city”]; 
$home_county = $_SESSION[“home_county”]; 
$home_district = $_SESSION[“home_district”]; 
$home_region = $_SESSION[“home_region”]; 
$home_state = $_SESSION[“home_state”]; 
$home_country = $_SESSION[“home_country”]; 
//$_SESSION Variables associated with ‘business_contact_details’ tbl. 
$business_blog = $_SESSION[“business_blog”]; 
$business_name = $_SESSION[“business_name”]; 
$business_email = $_SESSION[“business_email”]; 
$business_mobile = $_SESSION[“business_mobile”]; 
$business_land_line_phone = $_SESSION[“business_land_line_phone”]; 
$business_fax = $_SESSION[“business_fax”]; 
$business_zip = $_SESSION[“business_zip”]; 
$business_town = $_SESSION[“business_town”]; 
$business_neighbourhood = $_SESSION[“business_neighbourhood”]; 
$business_borough = $_SESSION[“business_borough”]; 
$business_city = $_SESSION[“business_city”]; 
$business_county = $_SESSION[“business_county”]; 
$business_district = $_SESSION[“business_district”]; 
$business_region = $_SESSION[“business_region”]; 
$business_state = $_SESSION[“business_state”]; 
$business_country = $_SESSION[“business_country”]; 
?>

[/code]

10

home_v1.php

[code]

<?php 

//Required PHP Files.  
include ‘config.php’; //Required on all webpages of the site. 
include ‘account_header.php’; //Required on all webpages of the account. 
include ‘sessions.php’; 

?> 
<!DOCTYPE html> 
<html> 
<head> 
<title><?php echo “$user “;?>Home Page</title> 
<meta charset=”utf-8″> 
</head> 
<body> 
<body background=”background.png”> 
<p align=”right”><a href=”settings.php?user=<?php echo “$user”;?>”>Settings</a>|<a href=’logout_v1.php’>Log Out</a>|</p> 
<h2><p align=”center”><?php echo “$user Home Page”;?></p></h2> 
<?php 
//Welcome User by name. 
echo “Welcome $first_name $middle_name $surname”;?> 
<br> 
<br> 
<p align = “center”><font color = “red”><b>Latest Follower</b></font><br> 
<iframe src=”https://www.yahoo.com” width=”100%” height=”500px”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<br> 
<p align = “center”><font color = “red”><b>Latest Followee</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<br> 
<p align = “center”><font color = “red”><b>Latest Recruit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<br> 
<p align = “center”><font color = “red”><b>Upline 1 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<p align = “center”><font color = “red”><b>Upline 2 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<p align = “center”><font color = “red”><b>Upline 3 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<p align = “center”><font color = “red”><b>Upline 4 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<p align = “center”><font color = “red”><b>Upline 5 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 
<p align = “center”><font color = “red”><b>Upline 6 Latest Visit</b></font><br> 
<iframe src=”http://google.com”> 
    <p>Your browser does not support iframes.</p> 
</iframe>
</p> 
<br> 

<?php 
//Display User Account Details 
echo “<h3>User: <a href=”user.php?user=$user”>$user</a> Details</h3>”;?><br> <?php  //CHANGELINK 
$user_account_details = array(“id_video_verification_status”,”id_verification_video_file_url”,”recruits_number”,”sponsor_username”,”username”,”primary_domain”,”primary_website_email”,”sponsor_username”,”recruits_number”,”registering_country”,”registering_ip”,”registering_browser”,”registering_os”,”registering_isp”,”age_range”); 
foreach ($user_account_details as $value) { 
$value_0 = str_replace(“_”,” “,”$value”); 
$value_0 = ucwords(“$value_0”); 
echo “<b>$value_0</b>: “; echo “${$value}”;?><br><?php 

//Display User Personal Details 
echo “<h3>Personal: <a href=”user.php?user=$user”>$user</a> Details</h3>”;?><br> <?php  //CHANGELINK
$user_personal_details = array(“personal_details_verified_by_recruiter”,”passport_size_photoh_image”,”title”,”first_name”,”middle_name”,”surname”,”gender”,”date_of_birth”,”skin_complexion”,”height”,”weight”,”sexual_orientation”,”marital_status”,”working_status”,”country_of_birth”,”bio”); 
foreach ($user_personal_details as $value) { 
$value_0 = str_replace(“_”,” “,”$value”); 
$value_0 = ucwords(“$value_0”); 
echo “<b>$value_0</b>: “; echo “${$value}”;?><br><?php 

//Display User Home Contact Details from home_contact_details tbl. 
echo “<h3>Home <a href=”user.php?user=$user”>$user</a> Details</h3>”;?><br> <?php  //CHANGELINK
$user_home_contact_details = array(“personal_blog”,”personal_email”,”personal_mobile”,”home_land_line_phone”,”home_fax”,”home_zip”,”home_town”,”home_neighbourhood”,”home_borough”,”home_city”,”home_county”,”home_district”,”home_region”,”home_state”,”home_country”); 
foreach ($user_home_contact_details as $value) { 
$value_0 = str_replace(“_”,” “,”$value”); 
$value_0 = ucwords(“$value_0”); 
echo “<b>$value_0</b>: “; echo “${$value}”;?><br><?php //NOTWORKING

//Display User Business Contact Details from business_contact_details tbl. 
echo “<h3>Business: <a href=”user.php?user=$user”>$user</a> Details</h3>”;?><br><?php  //CHANGELINK
$user_business_contact_details = array(“business_blog”,”business_name”,”business_email”,”business_mobile”,”business_land_line_phone”,”business_fax”,”business_zip”,”business_town”,”business_neighbourhood”,”business_borough”,”business_city”,”business_county”,”business_district”,”business_region”,”business_state”,”business_country”); 
foreach ($user_business_contact_details as $value) { 
$value_0 = str_replace(“_”,” “,”$value”); 
$value_0 = ucwords(“$value_0”); 
echo “<b>$value_0</b>: “; echo “${$value}”;?><br><?php //NOTWORKING

?> 
<br> 
<?php 
//Link Submitter FRame
//Link Submitter iFrame Goes here
?> 
<br> 
<br> 
<?php 
include ‘account_footer.php’; 
?> 

[/code]

11.

log_out_v1.php

[code]

<?php 
    session_start();
    session_destroy();
    echo “You have successfully logged-out of your account!”;
?>
<br>
<p align=”left”><font color=”red” size=”3″><b>Want to Log-in again ? </b><a href=”login_v1.php”>Login here!</a></font></p>

[/code]

On the home_v1.php, I should be echoing the row data through htmlentities. Right ?

REPEAT NOTE:

On the comments on home_v1.php, note the “//NOT WORKING”. This is where I am having trouble as data from the 2 tbls (home_contact_details, business_contact_details) are not getting grabbed and displayed.

You really need to check login_v1.php, sessions.php and home_v1.php. Other files provided for your convenience.

I wonder if I messed things up on the sessions variables. In that case you may check login_v1.php, sessions.php and ofcourse home_v1.php.

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 20.2018 — See if this helps before doing a redirect if already logged in:
[code=php]
$_SESSION['something'] = 'something';
session_write_close(); // <== this is the important thing
header('Location: https//www.example.com/some_page.php');
[/code]
Copy linkTweet thisAlerts:
@rootNov 20.2018 — > @site-developer#1598064 personal_blog = $_SESSION["personal_blog"]; 

> $personal_email = $_
SESSION["personal_email"]; 

> $personal_mobile = $_SESSION["personal_mobile"]; 

> $home_land_line_phone = $_
SESSION["home_land_line_phone"]; 

> $home_fax = $_SESSION["home_fax"]; 

> $home_zip = $_
SESSION["home_zip"]; 

> $home_town = $_SESSION["home_town"]; 

> $home_neighbourhood = $_
SESSION["home_neighbourhood"]; 

> $home_borough = $_SESSION["home_borough"]; 

> $home_city = $_
SESSION["home_city"]; 

> $home_county = $_SESSION["home_county"]; 

> $home_district = $_
SESSION["home_district"]; 

> $home_region = $_SESSION["home_region"]; 

> $home_state = $_
SESSION["home_state"]; 

> $home_country = $_SESSION["home_country"]; 

> //$_
SESSION Variables associated with 'business_contact_details' tbl. 

> $business_blog = $_SESSION["business_blog"]; 

> $business_name = $_
SESSION["business_name"]; 

> $business_email = $_SESSION["business_email"]; 

> $business_mobile = $_
SESSION["business_mobile"]; 

> $business_land_line_phone = $_SESSION["business_land_line_phone"]; 

> $business_fax = $_
SESSION["business_fax"]; 

> $business_zip = $_SESSION["business_zip"]; 

> $business_town = $_
SESSION["business_town"]; 

> $business_neighbourhood = $_SESSION["business_neighbourhood"]; 

> $business_borough = $_
SESSION["business_borough"]; 

> $business_city = $_SESSION["business_city"]; 

> $business_county = $_
SESSION["business_county"]; 

> $business_district = $_SESSION["business_district"]; 

> $business_region = $_
SESSION["business_region"]; 

> $business_state = $_SESSION["business_state"]; 

> $business_country = $_
SESSION["business_country"];


All that copuld be replaced with a simple extract( $_SESSION ); and all your variables are the names of the key names you use...
Copy linkTweet thisAlerts:
@NogDogNov 20.2018 — @root#1598070

Or just use $_SESSION['whatever'] wherever you need it, instead of creating a duplicate set of variables. ?
Copy linkTweet thisAlerts:
@site-developerauthorNov 20.2018 — @NogDog#1598076

Show me sample code what you mean because I now puzzled.
Copy linkTweet thisAlerts:
@site-developerauthorNov 20.2018 — @root#1598070

extract($_SESSION) ? Erm ? I am scratching my head. Care to elaborate ?
Copy linkTweet thisAlerts:
@site-developerauthorNov 20.2018 — Folks,



I switched login.php to these queries and now working:
<i>
</i> //Make sure the users table has atleast these 3 columns: username,primary_domain and website_email due to the $querying_column variable which could hold any of these 3 values.
$query_1 = "SELECT id,recruits_number,sponsor_username,account_activation_status,id_video_verification_status,id_verification_video_file_url,username,password,primary_domain,primary_website_email,registering_country,registering_ip,registering_browser,registering_os,registering_isp,age_range FROM users WHERE $querying_column = ?";
$stmt_1 = mysqli_prepare($conn,$query_1);
mysqli_stmt_bind_param($stmt_1,'s',$login_username_or_email_or_domain);
mysqli_stmt_execute($stmt_1);
$result_1 = mysqli_stmt_bind_result($stmt_1,$db_id,$db_recruits_number,$db_sponsor_username,$db_account_activation_status,$db_id_video_verification_status,$db_id_verification_video_file_url,$db_username,$db_password,$db_primary_domain,$db_website_email,$db_registering_country,$registering_ip,$registering_browser,$registering_os,$registering_isp,$db_age_range);
mysqli_stmt_fetch($stmt_1);
mysqli_stmt_close($stmt_1);
//Free Result_1 Set
mysqli_stmt_free_result($stmt_1);
<br/>
<i> </i>$query_2 = "SELECT title,first_name,middle_name,surname,gender,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,country_of_birth,bio FROM personal_details WHERE username = ?";
<i> </i>$stmt_2 = mysqli_prepare($conn,$query_2);
<i> </i>mysqli_stmt_bind_param($stmt_2,'s',$db_username);
<i> </i>mysqli_stmt_execute($stmt_2);
<i> </i>$result_1 = mysqli_stmt_bind_result($stmt_2,$db_title,$db_first_name,$db_middle_name,$db_surname,$db_gender,$db_date_of_birth,$db_skin_complexion,$db_height,$db_weight,$db_sexual_orientation,$db_religion,$db_education,$db_profession,$db_marital_status,$db_working_status,$db_country_of_birth,$db_bio);
<i> </i>mysqli_stmt_fetch($stmt_2);
<i> </i>mysqli_stmt_close($stmt_2);
<i> </i>//Free Result_2 Set
<i> </i>mysqli_stmt_free_result($stmt_2);
<i> </i>
<i> </i>$query_3 = "SELECT personal_blog,personal_email,personal_mobile,home_land_line_phone,home_fax,home_zip,home_town,home_neighbourhood,home_borough,home_city,home_district,home_county,home_region,home_state,home_country FROM home_contact_details WHERE username = ?";
<i> </i>$stmt_3 = mysqli_prepare($conn,$query_3);
<i> </i>mysqli_stmt_bind_param($stmt_3,'s',$db_username);
<i> </i>mysqli_stmt_execute($stmt_3);
<i> </i>$result_3 = mysqli_stmt_bind_result($stmt_3,$db_persona_blog,$db_personal_email,$db_personal_mobile,$db_home_land_line_phone,$db_home_fax,$db_home_zip,$db_home_town,$db_home_neighbourhood,$db_home_borough,$db_home_city,$db_home_district,$db_home_county,$db_home_region,$db_home_state,$db_home_country);
<i> </i>mysqli_stmt_fetch($stmt_3);
<i> </i>mysqli_stmt_close($stmt_3);
<i> </i>//Free Result_3 Set
<i> </i>//mysqli_stmt_free_result($stmt_3);
<i> </i>
<i> </i>$query_4 = "SELECT business_blog,business_name,business_email,business_mobile,business_land_line_phone,business_fax,business_zip,business_town,business_neighbourhood,business_borough,business_city,business_district,business_county,business_region,business_state,business_country FROM business_contact_details WHERE username = ?";
<i> </i>$stmt_4 = mysqli_prepare($conn,$query_4);
<i> </i>mysqli_stmt_bind_param($stmt_4,'s',$db_username);
<i> </i>mysqli_stmt_execute($stmt_4);
<i> </i>$result_4 = mysqli_stmt_bind_result($stmt_4,$db_business_blog,$db_business_name,$db_business_email,$db_business_mobile,$db_business_land_line_phone,$db_business_fax,$db_business_zip,$db_business_town,$db_business_neighbourhood,$db_business_borough,$db_business_city,$db_business_district,$db_business_county,$db_business_region,$db_business_state,$db_business_country);
<i> </i>mysqli_stmt_fetch($stmt_4);
<i> </i>mysqli_stmt_close($stmt_4);
<i> </i>//Free Result_4 Set
<i> </i>//mysqli_stmt_free_result($stmt_4);


Can you spot the typos ? Hey! That is a good idea for my social network: "Spot the typo!". ? I am going to build this game. ?

Look where the typo was:
<i>
</i>$query_4 = "SELECT business_blog,business_name,business_email,business_mobile,business_land_line_phone,business_fax,business_zip,business_town,business_neighbourhood,business_borough,business_city,business_district,business_county,business_region,business_state,business_country FROM business_contact_details WHERE id = ?"; $stmt_4 = mysqli_prepare($conn,$query_4); mysqli_stmt_bind_param($stmt_4,'s',$db_id); mysqli_stmt_execute($stmt_4); $result_3 = mysqli_stmt_bind_result($stmt_3,$db_business_blog,$db_business_name,$db_business_email,$db_business_mobile,$db_business_land_line_phone,$db_business_fax,$db_business_zip,$db_business_town,$db_business_neighbourhood,$db_business_borough,$db_business_city,$db_business_district,$db_business_county,$db_business_region,$db_business_state,$db_business_country); mysqli_stmt_fetch($stmt_4); mysqli_stmt_close($stmt_4); //Free Result_4 Set //mysqli_stmt_free_result($stmt_4);
Copy linkTweet thisAlerts:
@NogDogNov 21.2018 — @site-developer#1598088
Show me sample code what you mean because I now puzzled.[/quote]

All a statement like this does is assign a value that's already in one (session) variable into another variable:
$foo = $_SESSION['foo'];
You now have whatever that value is stored in two places using approximately twice as much memory (not really a big deal, but why?). What you'll probably tell me is that now it's easier to type. I'll respond: Who cares? If you're typing those variables over and over in your code, you're probably writing very un-D.R.Y. code. And what's a few more keystrokes, anyway? As a full-time software engineer, I spend the majority of my time *reading* code and analyzing problems, not typing. Besides, if you use $_SESSION['foo'] instead of $foo when you need that value, it's immediately apparent while reading that part of the code where that value came from -- you don't have to search for where $foo was defined if you need to understand where it came from. So...
[code=php]
// these two lines...
$foo = $_SESSION['foo'];
echo "Foo is set to $foo";

//...end up doing what this one line would do:
echo "Foo is set to '{$_SESSION['foo']}'";

// or if you prefer:
echo "Foo is set to'".$_SESSION['foo']."'";
[/code]

Always write your code as if you're going to have to fix it in a year or two, long after you forgot why you wrote it that way in the first place (because you will). Make it readable, easy to debug, and D.R.Y. (Don't Repeat Yourself).
Copy linkTweet thisAlerts:
@rootNov 21.2018 — Start here : https://www.w3schools.com/php/func_array_extract.asp
Copy linkTweet thisAlerts:
@site-developerauthorNov 22.2018 — @NogDog#1598099

Benanamen keeps telling me to not create unnecessary variables and now you too. Hence, will try heeding on version 2.
Copy linkTweet thisAlerts:
@rootNov 23.2018 — Why create a rod for your own back when you may or may not need all those variables, if you only need a few, then that is possibly the most appropriate way.

HOWEVER, the initial source of data in the arrays being stored, is this the by time stamp data? is this the by time stamp data?

It would help people to help you if you were to indicate exactly what it is you are trying to do.

The main question is this need for an array that is indexed by time stamp, if this data has come from a database, why on earth are you not using SQL to do the leg work and save on 100 or so lines of code?

Can you please describe page by page function and step by step the process you envisage and the ultimate goal of this process. It may be able to be simplified.
×

Success!

Help @site-developer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...