<?php session_start() ; ?> <form method="POST" action="page1.php"> <?php $value++ ; echo $value ; ?> <br> <input type="submit" value="Submit" name="B1"> </form>
In your version session_start() should be sent before any other output is sent.
Jochem
Thomas Edward Lawrence wrote:
this is page1.php <? session_start() ; echo $value ; if (!session_is_registered("value") ) { session_register("value") ; $value = 1 ; } echo $value ; ?> <br> <a href="page2.php">Next page</a>
this is page2.php
<form method="POST" action="page1.php"> <? session_start() ; $value++ ; echo $value ; ?> <br> <input type="submit" value="Submit" name="B1"> </form>
when I come back to page1.php from page2.php , this is result :
page1.php ( run at first time)
Warning: Cannot send session cookie - headers already sent by (output started at C:\PHP\page1.php:9) in C:\PHP\\page1.php on line 10
Warning: Cannot send session cache limiter - headers already sent (output started at C:\PHP\page1.php:9) in C:\PHP\page1.php on line 10
Notice: Undefined variable: value in C:\PHP\page1.php on line 11
1 (value of $value)
Next page
page2.php
Warning: Cannot send session cache limiter - headers already sent (output started at C:\PHP\page2.php :10) in C:\PHP\page2.php on line 11
2 (value of $value)
page1.php ( when come back from page2.php)
Warning: Cannot send session cookie - headers already sent by (output started at C:\PHP\page1.php :9) in C:\PHP\page1.php on line 10
Warning: Cannot send session cache limiter - headers already sent (output started at C:\PHP\page1.php:9) in C:\PHP\page1.php on line 10
Notice: Undefined variable: value in C:\PHP\page1.php on line 11 (browser not understanding $value)
1 (value of $value still 1)
Next page
Nothing changes , value of $value still is 1 , this question is so difficult , I also want to ask why my browser warns , how I must config in php.ini , I use IE6 , win2k , thank for reading .
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php