damoon 0 Report post Posted September 28, 2009 i built this php script to redirect a particular password to a page according to the password inputed....password= 237806422 <html><head><title>Redirector</title></head><body><FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><input type="text" name="pass"/><input type="submit" value="Enter"/></body></html><?php/////collect variables//////$pass = $_POST['pass']///////variables collected//////if $pass=="237806422" {header(location: main.php);}else{die;}?>please where did i go wrong? Share this post Link to post Share on other sites
manish-mohania 0 Report post Posted September 28, 2009 It should generate a headers already sent error message.Reason:header() method should not be used after you have outputted the html. In this particular case is the form.http://in.php.net/manual/en/function.header.php Share this post Link to post Share on other sites
damoon 0 Report post Posted September 28, 2009 so what should i do to correct the error? Share this post Link to post Share on other sites
hype 0 Report post Posted September 28, 2009 so what should i do to correct the error?Place the PHP scripting codes right at the start of the page, above the html codings. Share this post Link to post Share on other sites
damoon 0 Report post Posted September 28, 2009 but apart from that are u sure theres no other error/bugs??please go through it Share this post Link to post Share on other sites
BCD 1 Report post Posted September 28, 2009 but apart from that are u sure theres no other error/bugs??Well, you should be telling the answer to it. Did it run correctly after applying the changes? If not what is the error being shown? Share this post Link to post Share on other sites
hype 0 Report post Posted September 28, 2009 but apart from that are u sure theres no other error/bugs??please go through it I think you should instead do a run in your script and paste the error message here if there's any. I'm not a PHP compiler, don't expect me to run through the codes and generate the errors for you with my brain. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted September 28, 2009 (edited) Well, everything were bad in that script, I just fixed it, didn't try if it works, but I think it should work: <?phpif ( isset($_POST['pass']) && $_POST['pass'] == '237806422'){ header("Location: http://forums.xisto.com/no_longer_exists/;;'>http://forums.xisto.com/no_longer_exists/;; exit;}else{ exit;}?><html><head><title>Redirector</title></head><body><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><input type="text" name="pass" /><input type="submit" value="Enter" /></form></body></html> Replace http://forums.xisto.com/no_longer_exists/ with your website location, you need to use the full url path and not only main.php as you did before.. Also having so much errors in your code, I suggest you first read a tutorial on how to do something in PHP, because it seems that you don't know any basic stuff. Edited September 28, 2009 by Quatrux (see edit history) Share this post Link to post Share on other sites
nooc9 0 Report post Posted September 29, 2009 Well, everything were bad in that script, I just fixed it, didn't try if it works, but I think it should work: <?php if ( isset($_POST['pass']) && $_POST['pass'] == '237806422') { header("Location: http://forums.xisto.com/no_longer_exists/;; exit; } else { exit; } ?> <html><head><title>Redirector</title></head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="pass" /> <input type="submit" value="Enter" /> </form> </body></html> The html will never show because the script will exit before it reaches the html. The "else { exit; }" should be removed. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted September 29, 2009 Yes, you're right, that is what you get when you don't do any testing, I wrote it very fast and copied the content and made a really terrible mistake.. anyway remove the else { exit; } and it should work. Share this post Link to post Share on other sites
damoon 0 Report post Posted October 2, 2009 thanks anyways i guesss i will just have to test it now........but can i use die;instead of exit; ? Share this post Link to post Share on other sites