Jump to content

php redirect


Jackthumper

Recommended Posts

<?php
$get = fetch("SELECT number FROM dom");
if ($get == "1") {
    echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/down_for_maitenence.php'>";
} elseif ($get == "0") {
    echo "<meta http-equiv='refresh' content='0;url=http://toxicpets.co.uk/index.php'>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120513
Share on other sites

<?php
$get = fetch('SELECT number FROM dom');
if ($get == 1) {
    echo '<meta http-equiv="refresh" content="0;url=http://toxicpets.co.uk/down_for_maitenence.php">';
} elseif ($get == 0) {
    echo '<meta http-equiv="refresh" content="0;url=http://toxicpets.co.uk/index.php">';
}
?>

 

And this is not php redirect...

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120533
Share on other sites

<?php
$get = fetch('SELECT number FROM dom');
if ($get == 1) {
    echo '<meta http-equiv="refresh" content="0;url=http://toxicpets.co.uk/down_for_maitenence.php">';
} elseif ($get == 0) {
    echo '<meta http-equiv="refresh" content="0;url=http://toxicpets.co.uk/index.php">';
}
?>

 

And this is not php redirect...

He made it seem like he wanted php to carryout the else and if statements, not necessarily the redirect. So how about you offer the help you believe he needs before trying to correct my helpful input.

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120670
Share on other sites

the topic is php redirect, so..

 

Sorry, but i just hate single quotes in html

 

Yup, I agree, that's the only reason I looked in here. There are better ways to do this, and seriously, try to keep HTML & PHP seperate, this makes for easier code to read; and precisely why we use includes() & header() calls.

 

It's technically a html redirect, but the output is the same, well it looks the same!

 

Rw

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120890
Share on other sites

i prefer single quotes in HTML so I can include php variables without dropping out via "'.$something.'"

 

many mistakes are due to people using double quotes within a tag and single-quotes to surround the tag, but with $something as an uninterpreted string within the tag. so $something remains the string '$something' instead of the value of $something as expected. if you always use single-quotes in your html, this problem is negated.

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120894
Share on other sites

btw, the meta won't work for some bots, if it's turned off via browser, or if it functions improperly like on my current version of firefox. if you want to make sure the user is redirected, i would use header:

 

<?php
$get = fetch('SELECT number FROM dom');
if ($get == 1) {
    header("location: http://toxicpets.co.uk/down_for_maitenence.php");
    exit;
} elseif ($get == 0) {
    header("location: http://toxicpets.co.uk/index.php");
    exit;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120896
Share on other sites

That's just down to a preference thing, I personally find it easier to read when it's concatenated, but down to personal preference.

 

I never use a meta refresh purely for browser compatibility, you can set a delay via the header function:-

 

header("refresh:5; url=somepage.php");

 

Perfect, though there are some issues with it sometimes not working, though I haven't experienced this as yet.

 

And the example you give, it amazes me how many people don't put the exit after a header call! So I am pleased as you advocate this method.

 

Rw

Link to comment
https://forums.phpfreaks.com/topic/215481-php-redirect/#findComment-1120897
Share on other sites

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.