Jump to content

header help


halmstad

Recommended Posts

hi

i am new to PHP

im building a site where the user after authenticating will move to next page mian.php

i have both of my php pages inmy C drive how do i specify the location part in header

My code is

<?php

session_start();

 

$errorMessage = '';

if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {

    // check if the username and password combination is correct

    if ($_POST['txtUserId'] === 'theadmin' && $_POST['txtPassword'] === 'chumbawamba') {

        // the username and password match, 

        // set the session

        $_SESSION['basic_is_logged_in'] = true;

       

        // after login we move to the main page

        header('Location:main.php');

        exit;

    } else {

        $errorMessage = 'Sorry, wrong username / password';

    }

}

?>

pls do help me

Link to comment
https://forums.phpfreaks.com/topic/40509-header-help/
Share on other sites

First, put your code between CODE tags, it's easier to read and takes up less space.

 

You need to know your DOCUMENT_ROOT.  Type "echo $_SERVER['DOCUMENT_ROOT']" and that will tell you the base directory for everything.  So say your DOCUMENT_ROOT is "C:\".  If "main.php" is in the "C:\website\" folder, you just type: "header('Location: website/main.php').

 

Is that what you were asking?

Link to comment
https://forums.phpfreaks.com/topic/40509-header-help/#findComment-196005
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.