timgetback Posted August 3, 2006 Author Share Posted August 3, 2006 so would i add that java script to my php file??? cause when i added [code]include 'redirect.php';[/code] at the end it didnt redirect the url...... Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-68880 Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 note on using<META HTTP-EQUIV=Refresh CONTENT=\"10;url=rederict.php\">This does not seem to work on IE Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-68884 Share on other sites More sharing options...
Drumminxx Posted August 4, 2006 Share Posted August 4, 2006 Change this:[code]$sql = mysql_query("INSERT INTO users (username, password) VALUES('$username', '$passwd')") or die (mysql_error());$result = mysql_query($sql,$connection) or die (mysql_error()); [/code]to[code]$sql = "INSERT INTO users (username, password) VALUES('$username', '$passwd')";$result = mysql_query($sql,$connection) or die (mysql_error()); [/code]your using the result of the query instead of the query itself or you could just remove this line altogether if you prefer[code]$result = mysql_query($sql,$connection) or die (mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-68954 Share on other sites More sharing options...
corbin Posted August 4, 2006 Share Posted August 4, 2006 I prefer meta refreshes over PHP header redirects... I just like meta tags because they can be put anywhere though... i also use<script type="text/javascript>window.location = "http://somesite.com/page.php";</script>a lot. Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-68988 Share on other sites More sharing options...
timgetback Posted August 4, 2006 Author Share Posted August 4, 2006 when i typed the code you gave me:[code]<script type="text/javascript>window.location = "http://somesite.com/page.php";</script>[/code]It kept giving me this error:"Parse error: syntax error, unexpected '<' in /home/someplace/public_html/register3.php on line 31" line 31 happens to be the place where the above code started. Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69012 Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 well parse error is phpYou forgot to close the php<?//your php code?><script type="text/javascript>window.location = "http://www.example.com/page.php</script><?//Continue php?> Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69059 Share on other sites More sharing options...
Ifa Posted August 4, 2006 Share Posted August 4, 2006 or just [code=php:0]echo '<script type="text/javascript>window.location = "http://www.example.com/page.php</script>';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69108 Share on other sites More sharing options...
timgetback Posted August 4, 2006 Author Share Posted August 4, 2006 For some unexpected reason... neither the exho'script..........</script>'; works or even closing php... ?> and reopening works. Nothings seems to be redirecting my code... and i wanted to redirect after i was done with the output Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69200 Share on other sites More sharing options...
timgetback Posted August 5, 2006 Author Share Posted August 5, 2006 [quote author=SharkBait link=topic=102866.msg408914#msg408914 date=1154617365]Depends on what else you want to do.. Just remember that you cannot send any output to the browser prior to the header() and anything after won't be seen because its not on that page anymore.As for it continuing execution of the script after the header() function, I am not sure if it does any of it. I usually have exit() after my header() and then whatever else I need to do will be in the script that you're calling header with.[/quote]Ive gotten alot of conflicting messages.... like if i put ob_start(); and ob_flush(); in my code i can put the header() fuction anywhere.... unfortunately i tried n it didnt work but it could be the way i did it. i also tried echo ' script type="text/javascript>window.location = "http://somesit.com/index.php";</script>';but that didnt work... it didnt cause any errors but it didnt work.. so wats up? Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69640 Share on other sites More sharing options...
xec Posted August 5, 2006 Share Posted August 5, 2006 header("location: http://www.domain.com"); exit;------------------------ few mistake you need to correct in order to redirect your page...header("Location: http://www.domain.com");exit; Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69656 Share on other sites More sharing options...
timgetback Posted August 5, 2006 Author Share Posted August 5, 2006 i was just wondering can i send an html link with php mail:[code]$message= "The information is that blah blah blah blah echo "<a href=http://www.somesit.com">Here</a> to see wat im talkin about.";mail("email@domain","Account INfo",$message,"from: forcsee.site"); ?>[/code]cause it gave me this error: Parse error: syntax error, unexpected '<' in /home/getsam2/public_html/register3.php on line 30 Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69846 Share on other sites More sharing options...
AndyB Posted August 5, 2006 Share Posted August 5, 2006 [code]$message= "The information is that blah blah blah blah <a href='http://www.somesit.com'>Here</a> to see wat im talkin about.";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69858 Share on other sites More sharing options...
timgetback Posted August 5, 2006 Author Share Posted August 5, 2006 thanks.... but i was still hoping to figure out how i can redirect using header() or some other function at the end of my php script..... Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69860 Share on other sites More sharing options...
AndyB Posted August 5, 2006 Share Posted August 5, 2006 [quote author=timgetback link=topic=102866.msg410288#msg410288 date=1154799359]thanks.... but i was still hoping to figure out how i can redirect using header() or some other function at the end of my php script.....[/quote]You can only use header() if the script has not output ANYTHING to the browser. Example:[code]header("Location: thank_you.php");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69865 Share on other sites More sharing options...
timgetback Posted August 5, 2006 Author Share Posted August 5, 2006 ok... cause i tried to include 'redirect.php'; at the end of my script it didnt wok.... so when i used [code]echo "<SCRIPT language= javascript>window.location="http://www.somesite.com</script>';[/code]I keep getting this messgae: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/getsam2/public_html/register3.php on line 36 Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69869 Share on other sites More sharing options...
AndyB Posted August 5, 2006 Share Posted August 5, 2006 You need to be more careful with ' and "Maybe this'll work:[code]echo "<script type='text/javascript'>window.location=http://www.somesite.com</script>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69877 Share on other sites More sharing options...
timgetback Posted August 5, 2006 Author Share Posted August 5, 2006 I would to say thank you all for all your help... My Project was a complete success.... and all you guys KICK ASS!!!!!!! cause i had no chance in hell of completeing my project in the one week that i did it in... And i hope all my dumbass questions will help other noObs.... Quote Link to comment https://forums.phpfreaks.com/topic/16451-how-to-redirect-with-php/page/2/#findComment-69893 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.