Jackthumper Posted October 9, 2010 Share Posted October 9, 2010 <?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'>"; ?> is this code right??? Quote Link to comment Share on other sites More sharing options...
plznty Posted October 9, 2010 Share Posted October 9, 2010 <?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'>"; } ?> Quote Link to comment Share on other sites More sharing options...
ram4nd Posted October 9, 2010 Share Posted October 9, 2010 <?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... Quote Link to comment Share on other sites More sharing options...
plznty Posted October 9, 2010 Share Posted October 9, 2010 <?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. Quote Link to comment Share on other sites More sharing options...
ram4nd Posted October 10, 2010 Share Posted October 10, 2010 the topic is php redirect, so.. Sorry, but i just hate single quotes in html Quote Link to comment Share on other sites More sharing options...
rwwd Posted October 10, 2010 Share Posted October 10, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 10, 2010 Share Posted October 10, 2010 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. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 10, 2010 Share Posted October 10, 2010 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; } ?> Quote Link to comment Share on other sites More sharing options...
rwwd Posted October 10, 2010 Share Posted October 10, 2010 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 Quote Link to comment 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.