-4

This is my webpage headers :

<?php 

    header("Location: http://sreyas.org.in/main/index.php?user=<?php echo    
    $_SESSION['username']; ?>"); exit;
    header('Content-Type: text/html; charset=UTF-8');
    header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate, 
    post-check=0, pre-check=0'); // HTTP 1.1.
    header('Pragma: no-cache'); // HTTP 1.0.
    header('Expires: 0');
   ?>

But all I can see in my webpage is the following error :

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp\www\sreyas\main\index.php on line 5

What can i do?

tektiv
  • 14,010
  • 5
  • 61
  • 70

2 Answers2

1

header() function is already inside php tags. You don't have to double them. So try this:

header("Location: http://sreyas.org.in/main/index.php?user=".$_SESSION['username']);
Boshentz
  • 347
  • 2
  • 8
0

why again start php in

<?php
    header("Location: http://sreyas.org.in/main/index.php?user=<?php echo    
    $_SESSION['username']; ?>"); 
?>

simply use

<?php
$name=$_SESSION['username'];
header("Location: http://sreyas.org.in/main/index.php?user=".$name);
?>
Bharat Dangar
  • 527
  • 4
  • 20