dazza12345
Programmer
Hi all, what im trying to do is as follows:
I have a form, when the submit button is clicked, the values from the form elements will be saved into Session variables before a different php file is loaded. I require the session variable in the new php file that is loaded.
Here is the code that I have already:
index.php
test.php
However, at present, I cannot get any of the session variables to print on the screen in test.php, all I can get is the follwoing error:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fhlinux203/b/bewisebets.co.uk/user/htdocs/bewisepoker/test.php:1) in /home/fhlinux203/b/bewisebets.co.uk/user/htdocs/bewisepoker/test.php on line 2
Im sure this has something to do with the include './cookie-include.php'; line in index.php. As this line includes a php file that will save cookies.
has any1 got any idea how I could get around this error?
I have a form, when the submit button is clicked, the values from the form elements will be saved into Session variables before a different php file is loaded. I require the session variable in the new php file that is loaded.
Here is the code that I have already:
index.php
Code:
<?
ob_start();
include './cookie-include.php';
if(isset($_POST['submit_main'])) {
foreach($_POST as $key => $data) {
$_SESSION[$key] = $data;
}
header("Location: ./test.php");
exit();
}
?>
<form method=post action=<?php echo $_SERVER['PHP_SELF']; ?> name="myform" id="myform">
MANY FORM ELEMENTS
<input type="submit" name="submit_main" id-"submit_main" />
test.php
Code:
<?
session_start();
echo $_SESSION['banking'];
?>
However, at present, I cannot get any of the session variables to print on the screen in test.php, all I can get is the follwoing error:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fhlinux203/b/bewisebets.co.uk/user/htdocs/bewisepoker/test.php:1) in /home/fhlinux203/b/bewisebets.co.uk/user/htdocs/bewisepoker/test.php on line 2
Im sure this has something to do with the include './cookie-include.php'; line in index.php. As this line includes a php file that will save cookies.
has any1 got any idea how I could get around this error?