Jump to content

how to redirect with php.


timgetback

Recommended Posts

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]
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 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?
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 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]
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
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....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.