php redirect doesn't change the url -
i know common question, not find answer
i'v post.php, submit post form controller.php when goes right, in controller does:
header("location: ./post?ok=1"); the post inserted, , goes through line above, url in browser seems never changed, , @ end there not ok param,
i use session variable store such success/failure param, way should working
post.php:
<form action="controller" method="post"> <input name="test" value='test' type="text" /> <input type="submit" value="post" /> </form> controller.php:
<?php header("location: ./post?ok=1"); ?> edit 1:
header("refresh:1;url=http://localhost/test/post?ok=1"); //doesn't work better edit 2:
in post.php top i've put
debug("post l ".count($_post)); debug("get l ".count($_get)); they show 0's before submit, , 0's after also
edit3: works
was blocked by:
if ($success){ header("location: ./post?ok=1"); } header("location: ./post"); that should be:
if ($success){ header("location: ./post?ok=1"); } else { header("location: ./post"); } thx all
first of should not use $_server['http_referer'] unsafe. possible client won't send header anyway. right don't know how i'm sure used highjack site evil.
better should know form data came , redirect user there back.
by way redirect maybe don't work expected because url contain questionmark. have add more parameters & sign.
for redirect suggest http 302 found response status. have sure nothing other send out before. there must no html output or empty lines before following header line:
header("location: http://".$_server['http_host']."/your/source.form", true, 302);
Comments
Post a Comment