Jump to content
#FlattenTheCurve ×
zer0uk

header not redirecting

Recommended Posts

Hello I have moved my web site from local machine to a hosted server (Ionos) I seem to be having issues with any code that has redirects  or checks if the user is logged in, I just get a blank page, any idea's ? works fine on my local Xamp version two examples below (if I remove the code the page runs)

 

// 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'])) {
        header('Location: login.php');
        exit();
        }
?>

 

 

 

<?php  
       // database connect
        include('../db_connect.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'])) {
	    header('Location: login.php');
	    exit();
        }
        // if submit button selected  run code
        if(isset($_POST['submit'])){
                $_SESSION['district'] = $_POST['district'];
                header('Location: add_d_choice.php');
            }   
?>
<!DOCTYPE html>
<html>

<head>

</head>

 

Share this post


Link to post
Share on other sites

Recheck your code to make sure there is nothing being output (including white space) prior to the headers. You don't show all your code but I'm guessing there is some output preceding the header.

Share this post


Link to post
Share on other sites

And turn on php error checking - it will probably point out the error GW has diagnosed with a line number

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.