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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.