Welcome Guest, Not a member yet? Register   Sign In
Another redirect issue (profile page)
#1

(This post was last modified: 05-23-2019, 09:22 PM by Mekaboo.)

Howdy!

I obtained codes from 2 sites  for a profile page also redirect controller and tweaked them for what I wanted. Here is the code for both:

profile.php
<?php
// We need to use sessions, so you should always start sessions using the below code.
session_start();
// If the user is not logged in redirect to the login page...
if (!isset($_SESSION['loggedin'])) {
    redirect(base_url("redirect_controller/v2"));
    exit();
}
$DATABASE_HOST = '50.87.144.41';
$DATABASE_USER = 'cultured_root';
$DATABASE_PASS = 'brownie81';
$DATABASE_NAME = 'cultured_codeignite';
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
    die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
// We don't have the password or email info stored in sessions so instead we can get the results from the database.
$stmt = $con->prepare('SELECT password, email FROM accounts WHERE id = ?');
// In this case we can use the account ID to get the account info.
$stmt->bind_param('s', $_SESSION['id']);
$stmt->execute();
$stmt->bind_result($password, $email);
$stmt->fetch();
$stmt->close();
?>

redirect_controller.php
<?php
   class Redirect_controller extends CI_Controller {
    
      public function index() {
        
      }
      
      public function v2() {
         /*Load the URL helper*/
         $this->load->helper('url');
   
         /*Redirect the user to some internal controller’s method*/
         redirect('profile');
      }
        
   }
?>

I changed the original header in profile page and made it a redirect but get a 404 error. My goal is to connect profile page to DB so when folks login the page would be specifically for that person. FYI after one logs in they're directed to a dashboard, all of this works fine. From the dashboard want connect with profile page(think social network or a forum like this one). How do I connect and redirect?

Heart Heart ,
Mekaboo
Reply


Messages In This Thread
Another redirect issue (profile page) - by Mekaboo - 05-23-2019, 09:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB