PHP help!  | |
July 31st, 2006, 06:19 AM
|
#1 (permalink)
| | Member
Join Date: Nov 2005
Posts: 120
|
anyone know whats the code to connecting to another url?
this is what i wanted to do.
<?
$link=mysql_connect("localhost")or die("Could not connect");
mysql_select_db("cs259")or die("Could not select database");
$query="select * from epitaph where uname='" . $_REQUEST["uname"] . "'";
$result=mysql_query($query);
if(mysql_num_rows($result)==0)
{ "GO TO AN URL"
}
else{
[B]"GO TO ANOTHER URL"[/b]
}
mysql_close($link);
?>
can i do this in php? please help, tnx |
| |
July 31st, 2006, 03:17 PM
|
#2 (permalink)
| | SoMuchAnime-SoLittleTime
Join Date: Aug 2003 Location: Plymouth, WI
Posts: 14,983
|
Try Code: header("Location: http://www.example.com/"); Leave the Location: part. Just change the http://www.example.com/ to change the url.  |
| |
August 1st, 2006, 04:22 AM
|
#3 (permalink)
| | Member
Join Date: Nov 2005
Posts: 120
|
tried this :
<?
$link=mysql_connect("localhost")or die("Could not connect");
mysql_select_db("cs259")or die("Could not select database");
$query="select * from epitaph where uname='" . $_REQUEST["uname"] . "'";
$result=mysql_query($query);
if(mysql_num_rows($result)==0)
{
header("Location: http://localhost/saint/failed.php");
}
else{
header("Location: http://localhost/saint/myquiz.php");
}
mysql_close($link);
?>
but gave me this error:
Warning: Cannot modify header information - headers already sent by (output started at D:\cs259garcia\check.php:9) in D:\cs259garcia\check.php on line 17 |
| |
August 1st, 2006, 08:56 AM
|
#4 (permalink)
| | Senior Member
Join Date: May 2003 Location: Aus, Gold Coast :)
Posts: 802
|
hey mate, found some code i did ages ago and i think it is
window.frames[1].location = "<enter url here>";
though this is used for frames, i guess u just go:
window.location = "<enter url here>";
that does work though  , well the top one, might test the second now |
| |
August 1st, 2006, 10:17 AM
|
#5 (permalink)
| | Member
Join Date: Oct 2001 Location: Louisiana, USA
Posts: 256
|
Try placing this at the very top of your script (it allows headers to be sent after output has already been sent to the browser)
This changes the setting at runtime (Not 100% sure this one can be changed at runtime but give it a shot)... PHP Code: <?php ini_set('output_buffering','On'); ?>
Last edited by drizzle : August 1st, 2006 at 11:03 AM.
|
| |
August 2nd, 2006, 03:20 AM
|
#6 (permalink)
| | Member
Join Date: Nov 2005
Posts: 120
|
tried it both, but no luck! |
| |
August 2nd, 2006, 07:13 AM
|
#7 (permalink)
| | Ultimate Member
Join Date: Dec 2004
Posts: 1,558
|
If you aren't able to do it sending headers, your best bet is to use a meta redirect: PHP Code: echo '<meta http-equiv="Refresh" content="0;url=http://www.domain.com/">';
exit;
Where the number before the semi-colon is the number of seconds before the page is redirected; 0 works well.
Just note that meta redirects can be disabled within browsers. So you may want to provide the user with a link: PHP Code: echo '<meta http-equiv="Refresh" content="0;url=http://www.domain.com/">';
echo '<A HREF="http://www.domain.com/">Click here</A> if you\'re not automatically redirected';
exit;
__________________
"Be quiet, Brain, or I'll stab you with a Q-tip"
-Homer Simpson
|
| | | Thread Tools | Search this Thread | | | |
Similar Threads | | Thread | Thread Starter | Forum | Replies | Last Post | | php coding assistance with templete.php | herbal_lavender | Webmastering and Programming | 2 | December 29th, 2005 09:35 AM | | index.php?mode=something.php | RyanD | Webmastering and Programming | 16 | October 20th, 2004 11:20 PM | | More PHP Help | Rand Dusing | Webmastering and Programming | 3 | September 6th, 2004 11:51 AM | | php help | BlueIce | Webmastering and Programming | 0 | August 28th, 2004 05:45 PM | | PHP under M$ | SysRq | Webmastering and Programming | 25 | August 6th, 2002 05:01 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |