购物.php
<html>
<head>
<?php
if(isset($_POST['sub'])){
$a=$_POST['prod'];
$b=$_POST['qty'];
$_SESSION[$a]=$b;
}
?>
</head>
<body>
<form method="post" action="Billing.php">
Select any Product:
<select name="prod">
<option>Nokia</option>
<option>Reliance</option>
<option>Samsung</option>
<option>LG</option>
</select>
<br><br>
Quantity:<input name="qty"> <br><br>
<input type="submit" name="sub" value="ADD">
</form>
</body></html>
计费.php
<html>
<head>
<?php
session_start();
echo session_id();
echo "<br>";
echo "selected products are:<br>";
// print_r($_SESSION);
foreach($_SESSION as $x=>$y){
echo "product is $x and Quantity is:$y<br>";
}
?>
</head> </html>
输出
Warning: session_start() [function.session-start]: Cannot send session cookie -
headers already sent by (output started at E:\PHP programs\Billing.php:2) in E:\PHP programs\Billing.php on line 4
Warning: session_start() [function.session-start]: Cannot send session cache limiter -
headers already sent (output started at E:\PHP programs\Billing.php:2) in E:\PHP programs\Billing.php on line 4
请任何人提供上述警告消息的解决方案,我怎样才能成功执行程序?