pooker Posted June 25, 2008 Share Posted June 25, 2008 Ok I will try to describe this the best I can. I have a script that performs calls another script when the submit button and passes the information via the post method. It retrieves the information ok on the next script but the problem is the script is constantly refreshed so I need to keep this value I got from the post method so I tried this $chap = $_POST['url']; I did this below because the script refreshes constantly so it would only store the value once if ( $chap >= 1 ) { $num = $chap; } You can see where it stores the variable so I need a way to keep this number the same $dir = "./mangareader/bleach/chapter$num/"; so I read up on hidden variables I am was to think that this is how you do it so I tried above the submit button on this script and below it and it does not work <input type="submit" name="submit" value="Next"> <input type="hidden" name="num" value="<?php print $num?>"> I need it to keep the $num value but it is not doing it. All help is appreciated Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/ Share on other sites More sharing options...
vbnullchar Posted June 25, 2008 Share Posted June 25, 2008 you can use session() Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/#findComment-573989 Share on other sites More sharing options...
pooker Posted June 25, 2008 Author Share Posted June 25, 2008 I tried that but it still did not work maybe you can tell me what I did wrong please? On the initial script that uses the post method I used session_start(); there then on the script that is constantly refreshed I did this $chap = $_POST['url']; if ( $chap >= 1 ) { $_SESSION['num'] = $chap; } $num = $_SESSION['num']; $dir = "./mangareader/bleach/chapter$num/"; it is not keeping the session for some reason? Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/#findComment-574001 Share on other sites More sharing options...
jaoudestudios Posted June 25, 2008 Share Posted June 25, 2008 you need session_start() at the top of all the scripts, unless they are included (include/required) Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/#findComment-574015 Share on other sites More sharing options...
pooker Posted June 25, 2008 Author Share Posted June 25, 2008 Yes I tried that and this is what it does if I put session start on the other script Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/page.php:2) in /var/www/page.php on line 3 Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/#findComment-574017 Share on other sites More sharing options...
jaoudestudios Posted June 25, 2008 Share Posted June 25, 2008 make sure you send nothing to the browser before this line - even white space. a common mistake is a space before the opening php tag. If you are still having issues copy and paste the code Link to comment https://forums.phpfreaks.com/topic/111816-passing-variables-in-hidden-forms/#findComment-574451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.