Sign in to follow this  
onceloving

[web] PHP HELP

Recommended Posts

onceloving    106
I can't seem to figure out why these functions don't work like they should work. Can someone help me? <html> <?php echo $mark; session_start(); if ($_POST["action"] == "Previous 20") { $mark = $mark - 20; } if ($_POST["action"] == "Next 20") { $mark = $mark + 20; } if ($_POST["action"]) { ?> <script>window.location="<?php echo $PHP_SELF?>?mark=<?php echo $mark?>"</script> <? } ?> <body> <form method="post" action="<?php echo $PHP_SELF?>"> <input type=submit name="action" value="Next 20"> <input type=submit name="action" value="Previous 20"> </form></body></html>

Share this post


Link to post
Share on other sites
benryves    1999
Quote:
Original post by Invader X
You must use session_start() before you send anything to the browser, like your opening html tag.
To add to this: anything includes whitespace, which can catch you out. I also reckon <?php echo $PHP_SELF?> should be <?php echo $_SERVER['PHP_SELF']; ?> (I don't know if that would break, though). Forms will sumbit to the page they are on if you don't specify an action parameter, too.

Share this post


Link to post
Share on other sites
markr    1692
You can't just use $mark and imagine that it will somehow magically be preserved between pages.

Use $mark = $_REQUEST['mark'] or something similar. Add "mark" as a hidden field to the form.

Ensure that register_globals is off - it's a misfeature and will confuse you and break your apps in subtle and dangerous ways.

Mark

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this