phpsane Posted November 20, 2018 Share Posted November 20, 2018 (edited) 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. test.sql -- 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', 'loudwoman@gmail.com', 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', 'spaceman@gmail.com', 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', 'santa_clause@gmail.com', 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', 'wonderwoman@gmail.com', 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', 'admin@gmail.com', 'admin123', 1, '', NULL, NULL, '', '', ''), (1, '2018-11-20 19:21:34', '1300bf1542f6e6261f606542c2320bbb9efaf360', 1, 1, NULL, 'admin1234', '$2y$10$tM9gMGQ6Z6wNxJ/t8neIKOtQcRk1WwQIEBqxo55SgUwv710nfj0m2', 'yahooinvader.co.uk', 'gobot@yahoo.co.uk', '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', 'admin1234@fnulll.com', '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 */; 1. config.php <?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'; ?> 2. functions_list.php <?php //All FUNCTIONS List File. include 'login_check.php'; ?> 3. error_reporting.php <?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); ?> 4. site_details.php <?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 = "admin@test.com"; $social_network_admin_username = "admin123"; $social_network_admin_email = "admin@test.com"; $server_time = "California,USA"; ?> 5. conn.php <?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(); } ?> 6. login_check.php <?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; } } ?> 7. account_header.php <?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. } ?> 8. login_v1.php <?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> 9. sessions.php <?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"]; ?> 10 home_v1.php <?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'; ?> 11. log_out_v1.php <?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> On the home_v1.php, I should be echoing the row data through htmlentities. Right ? 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. Edited November 20, 2018 by phpsane Quote Link to comment Share on other sites More sharing options...
requinix Posted November 20, 2018 Share Posted November 20, 2018 You posted far too much code. People don't want to read through it all trying to track down the problem. Post the relevant parts of it. Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 (edited) 14 minutes ago, requinix said: You posted far too much code. People don't want to read through it all trying to track down the problem. Post the relevant parts of it. 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. Thanks! Edited November 20, 2018 by phpsane Quote Link to comment Share on other sites More sharing options...
requinix Posted November 20, 2018 Share Posted November 20, 2018 Your queries all assume that the ID of the table is the same value as the user ID. Is that true? Have you looked at the data yourself to see if everything is there the way you think it is? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 20, 2018 Share Posted November 20, 2018 Easy enough to check your session data in home.php echo '<pre>', print_r($_SESSION, 1), '</pre>'; Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 40 minutes ago, requinix said: Your queries all assume that the ID of the table is the same value as the user ID. Is that true? Have you looked at the data yourself to see if everything is there the way you think it is? Spot on Sweetheart! What a cockup I made! Arggh! Wasted half a wk on this silly mistake! Thanks a million! I should have queried the Username instead for the other tbls. And yes, Usernames are unique as they should be. Lol! Quote Link to comment Share on other sites More sharing options...
Barand Posted November 20, 2018 Share Posted November 20, 2018 The only place the username should exist is in the user table. The users' ids should be stored in the other tables instead of the name. Similarly, the only session value you should be storing in $_SESSION is the id of the logged on user. You then get the other data when you want it by querying the database using that stored id. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 20, 2018 Share Posted November 20, 2018 10 minutes ago, phpsane said: Spot on Sweetheart! I hope you two will be very happy together ? 1 Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 Folks, I switched login.php to these queries and now working: //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 username = ?"; $stmt_2 = mysqli_prepare($conn,$query_2); mysqli_stmt_bind_param($stmt_2,'s',$db_username); 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 username = ?"; $stmt_3 = mysqli_prepare($conn,$query_3); mysqli_stmt_bind_param($stmt_3,'s',$db_username); 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 username = ?"; $stmt_4 = mysqli_prepare($conn,$query_4); mysqli_stmt_bind_param($stmt_4,'s',$db_username); mysqli_stmt_execute($stmt_4); $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); mysqli_stmt_fetch($stmt_4); mysqli_stmt_close($stmt_4); //Free Result_4 Set //mysqli_stmt_free_result($stmt_4); Did as she Requinix suggested! Fixed the typoes here too: $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); 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. Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 (edited) 17 minutes ago, Barand said: I hope you two will be very happy together ? Oh come-on man! It's nearly Christmas and she sorted my half-a-wk wasted problem out in an hr! I'm in a jolly mood! She won't mind. Let's not push our lucks too much or you might get demoted and me banned. You see, I'm what you'd called "old fashioned". Clint Eastwood or Dirty Harry type. Not used to women-folk scoring against men or helping us out. And so, when a female (or, should I say "girliey") fixes something I couldn't. Then, what can I say ? We either hate em or start loving them. Starting to get a soft spot for Requinix after figuring it's a female. Lol! Female programmer. Wow! You don't see that much! I tell you what. You help me fix my pagination with prep stmt and I will call you: "Spot on mate!" How about "matey"? Or better: "Dude!" What-about "Dudey" ? Lol! If I was a girlie myself, I'd make the same compliment to you. You helped me out tonnes. And, I'm planning on talking you into a few more before I move-onto pdo from mysqli. Edited November 20, 2018 by phpsane Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 16 minutes ago, Barand said: The only place the username should exist is in the user table. The users' ids should be stored in the other tables instead of the name. Similarly, the only session value you should be storing in $_SESSION is the id of the logged on user. You then get the other data when you want it by querying the database using that stored id. I did not really want to clog the mysql db with too many queries as the db would be busy logging webspages my web proxy users are viewing. Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 20, 2018 Share Posted November 20, 2018 phpsane, Are you familiar with git? I would highly suggest at this point, that you make a github account (entirely free) or a bitbucket account. Start to push your code to github. At that point, it would be possible for those that choose to do so, to help you with your codebase in an efficient and professional manner. Questions regarding individual snippets at the function or paragraph level are appropriate for these threads. Too much code and people's eyes glaze over. I'm willing to go so far as to (once you've installed git) give you the basic commands needed to intialize add code and commit it to your repo, and to push it to your remote repository (github or bitbucket). Quote Link to comment Share on other sites More sharing options...
phpsane Posted November 20, 2018 Author Share Posted November 20, 2018 2 minutes ago, gizmola said: phpsane, Are you familiar with git? I would highly suggest at this point, that you make a github account (entirely free) or a bitbucket account. Start to push your code to github. At that point, it would be possible for those that choose to do so, to help you with your codebase in an efficient and professional manner. Questions regarding individual snippets at the function or paragraph level are appropriate for these threads. Too much code and people's eyes glaze over. I'm willing to go so far as to (once you've installed git) give you the basic commands needed to intialize add code and commit it to your repo, and to push it to your remote repository (github or bitbucket). I heard of github but I'm wondering if you are being sarcastic to call me a "git". LOl! Tell me that, that is not the case. Ok. I will checkout github and if anything puzzles me I'll bugger you to tell me more. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 20, 2018 Share Posted November 20, 2018 Enough is enough, guys. Keep the commentary about programming. 1 Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 21, 2018 Share Posted November 21, 2018 21 hours ago, Barand said: Easy enough to check your session data in home.php echo '<pre>', print_r($_SESSION, 1), '</pre>'; Just a quick note. If you have strict_types enabled this will not work and cause a Fatal error. You will need to use true for the second parameter. Problem: <?php declare(strict_types=1); echo '<pre>', print_r($_POST, 1), '</pre>'; Corrected <?php declare(strict_types=1); echo '<pre>', print_r($_POST, true), '</pre>'; 1 Quote Link to comment Share on other sites More sharing options...
Barand Posted November 21, 2018 Share Posted November 21, 2018 (edited) I've never used strict types, so thanks for the heads up. Edited November 21, 2018 by Barand Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.