Hi i'm doing some php i make login page where i check if user put right information i redirect him/her to index.php where session starts and other things occur.But when i put right username and password it not going to index.php else it coming back to login.php again.
Here is login.php

<?php
require_once("../../includes/database.php");
require_once("../../includes/functions.php");
require_once("../../includes/user.php");
require_once("../../includes/session.php");
if($session->is_logged_in())
{ redirect_to(index.php); }
//redirect_to("index.php");

if(isset($_POST['submit'])) //... if submit button is clicked
{
   $username = trim($_POST['username']);
   $password = trim($_POST['password']);

// check in database to see if username/password exist
$found_user = User::authenticate($username,$password);
// if we get some record in var $found_user
if($found_user)
   {
   $session->login($found_user);
  // echo $found_user->username;  // here is problem not redirecting
   redirect_to("index.php");        // this method is user define in function.php 
   } else {                          //where i put header()
   $message =  "Password/Username combination is not correct.";
   }
}  else  {
      $username ="";
      $password ="";
}
?>
<html>
  <head>.......

here is function.php

<?php function redirect_to( $location = NULL ) { if ($location != NULL) { header("Location: {$location}"); exit; } }

function output_message($message="") { if (!empty($message)) { return "<p class=\"message\">{$message}</p>"; } else { return ""; } } ?> [/cpde]

i on output buffering in php.ini so it can send header information after other but not working ... any suggestion.... plzzzzzzzzzzzzzzzzzz[code=php]
<?php
function redirect_to( $location = NULL ) {
if ($location != NULL) {
header("Location: {$location}");
exit;
}
}

function output_message($message="") {
if (!empty($message)) {
return "<p class=\"message\">{$message}</p>";
} else {
return "";
}
}
?>
[/cpde]

i on output buffering in php.ini so it can send header information after other but not working ...
any suggestion.... plzzzzzzzzzzzzzzzzzz

{ redirect_to(index.php); } needs to be in quotation marks: { redirect_to("index.php"); } Then go to index.php and make sure the page starts with:
<?php
session_start();

ya by doing this and changing some bad code in my session.php now its fine thanx alot without these forums i gona give up ..
thanx

Glad to help.

PS: Don't forget to mark this thread as Solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.