freakus_maximus Posted April 25, 2006 Share Posted April 25, 2006 This a snippet of code that allows me to determine if a record is locked in the table. All that works fine. But what I need to do is redirect if the record is locked to a page that tells the user it is locked, etc...otherwise continue with the code if not locked.FYI - I am open to suggestions if I am going about this the wrong way...lol.[code]$time_now = time();$allowed_time = $time_now-30000; if($is_locked>$allowed_time) { echo ("Record is locked");//Need to redirect to a page with a record locked notice. } else { echo ("Editing is allowed");//Editing form is in html/php mix below this}[/code]The rest of the code is a large mix of html and php w/ mysql queries where needed for dropdowns, etc...which all ends in a form to submit the edited information. Trying to avoid having to "echo" all the various html pieces out and figured if I could redirect conditionally this would solve the problem real quick.Thanks for any help. Quote Link to comment Share on other sites More sharing options...
Ferenc Posted April 25, 2006 Share Posted April 25, 2006 Use header() but it won't work if any output is sent before calling it.[code]<?php$time_now = time();$allowed_time = $time_now-30000;if($is_locked>$allowed_time) { header("Location: locked.php");//Need to redirect to a page with a record locked notice. exit; // no more code should be executed} else { echo ("Editing is allowed");//Editing form is in html/php mix below this}[/code] Quote Link to comment Share on other sites More sharing options...
freakus_maximus Posted April 26, 2006 Author Share Posted April 26, 2006 [!--quoteo(post=368660:date=Apr 25 2006, 07:04 PM:name=Ferenc)--][div class=\'quotetop\']QUOTE(Ferenc @ Apr 25 2006, 07:04 PM) [snapback]368660[/snapback][/div][div class=\'quotemain\'][!--quotec--]Use header() but it won't work if any output is sent before calling it[/quote]Well that will not work then. The whole page is rendered within the index.php page. Any other solutions or ideas for for doing this? I'm stumped. Quote Link to comment Share on other sites More sharing options...
freakus_maximus Posted April 26, 2006 Author Share Posted April 26, 2006 *bump* Quote Link to comment Share on other sites More sharing options...
samshel Posted April 26, 2006 Share Posted April 26, 2006 Hello,First try the header function. if it does not work then i think another alternative is using javascript to redirect:[code]<?php$time_now = time();$allowed_time = $time_now-30000;if($is_locked>$allowed_time) { echo "<script language=javascript>document.location.href='locked.php';</script>"; exit;} else { echo ("Editing is allowed");//Editing form is in html/php mix below this}?>[/code] Quote Link to comment Share on other sites More sharing options...
freakus_maximus Posted April 26, 2006 Author Share Posted April 26, 2006 Got it working! /cheerThanks! 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.