PHP_CHILD Posted January 14, 2013 Share Posted January 14, 2013 I now am missing something silly here.. but can't figure out....If someone has time, pls tell me where is tat am doing wrong?? <?php $a; if($a) { echo "want to use header to redirect"; } ?> <html> <form action="aa.php" method="post"> <input type="submit" value="submit"> </form> </html> <?php if(condition_true_after_submit_pressed) { echo "okkk"; $a=true; } ?> Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/ Share on other sites More sharing options...
requinix Posted January 14, 2013 Share Posted January 14, 2013 The only thing possibly resembling a question that you've said is about how to redirect to the top of the page. To do that... redirect to the page. Don't do anything special. It's just a normal redirect. Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/#findComment-1405520 Share on other sites More sharing options...
PHP_CHILD Posted January 14, 2013 Author Share Posted January 14, 2013 The only thing possibly resembling a question that you've said is about how to redirect to the top of the page. To do that... redirect to the page. Don't do anything special. It's just a normal redirect. thank for d respones.. But this is my code.... <?php if($a) { echo "want to use header to redirect"; } ?> <html> <form action="aa.php" method="post"> <input type="submit" value="submit" name="submit"> </form> </html> <?php if((isset($_POST['submit']))&& ($_POST['submit'])) { echo "okkk"; $a=true; } ?> can u tell me why doesn't it echos??? echo "want to use header to redirect";... it echos "okkk"... does this have anything2 do with variables...???Help plssss.... Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/#findComment-1405525 Share on other sites More sharing options...
requinix Posted January 14, 2013 Share Posted January 14, 2013 Well, as far as I can tell you expect the $a=true you have at the bottom of the script to affect the if($a) you have at the top of the script. Causality doesn't work that way: define the variable first, use the variable second. Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/#findComment-1405526 Share on other sites More sharing options...
PHP_CHILD Posted January 14, 2013 Author Share Posted January 14, 2013 Well, as far as I can tell you expect the $a=true you have at the bottom of the script to affect the if($a) you have at the top of the script. Causality doesn't work that way: define the variable first, use the variable second. ok so let me tell u want am tryin to do.. i have a submit form, which when clicked must be directed to another page. As i know, headers is placed before any output/html stms, i kept it at the top. To be executed.. Is der any other way to solve my problems.. Manys thanks for d responses.... Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/#findComment-1405530 Share on other sites More sharing options...
BrettHartel Posted January 14, 2013 Share Posted January 14, 2013 When using a form action to send the form input to another page you do not need a header that redirects. Clicking the form button will automatically redirect you. Link to comment https://forums.phpfreaks.com/topic/273127-php-beginner-want-to-redirect-to-top-of-page/#findComment-1405536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.