Jump to content

matleeds

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

matleeds's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks for the help and extensive coding there but my problem has been solved by one line and one function $tomorrow = strtotime("tomorrow"); returns the unix datetime for the next day from midnight....just what the doctor ordered
  2. hi, I have some code that deals with sending out reminders for appointments due the following day. So if today is the 21/3 then only reminders for appointments due on the 22/3 should be sent. Currently this isn't happening... If reminders are sent on 21/3 at 9.50 am, my code adds 24 hours to this datetime and sends reminders due for all appointments that fall bewteen 21/3 9.50am and 22/3 9.49 am. What I want to do is simply send all reminders for appointments that are on the 22/3 exclusive of time. I'm not sure how do this in php, which uses the unix datetime format to mildy complicate issues anhy help or solutions would be massive, thanks.how to $days = time() + (1 * (60 * 60 * 24)); $apts = $db->fetch_all('status = 1 AND time > ? AND time < ?', array(time(), $days));
  3. thanks. how would one use that if ? : statement in this context
  4. Hi, I'd like to know what the most efficient code is for checking the first 2 digits of a string. eg a strings first 2 digits must equal '07' thanks,
  5. Hi, I'm struggling a bit with using a date format and strtotime() if(!empty($_GET['utime'])) { $time = strtotime($_GET['utime']); } utime is supplied in the format dd/mm/yyyy but when I use strtotime() it treats it as mm/dd/yyyy....so 07/12/2011 is taken as 12th Aug rather than 7th Dec..which is the date I want to use. I had a quick ganders through the forums but couldn't find anything specific to this. is there any other attributes to strtotime() that will help, or a similar fucntion or a neat way of swoping my dd/mm/yyyy round before i use strtotime() any help greatly appreciated...
  6. won't break break out of the second foreach then continue with the remaining code in the first foreach before returning to the next iteration? I don't want to continue with the first foreach's remaining code but go straight to the start of next iteration. apologies if i'm wrong i haven't tried your suggestion yet.
  7. Hi, I'd like to know what the best way of breaking out of a nested foreach loop is..but not breaking out of the first foreach ears the code like, foreach ($apts as $apt) { foreach($rdb as $rem) { // Check to see if we've already sent a reminder for this appointment if($apt->id == $rem->appid) { // TODO get out of this foreach and go to the next iterartion of the first foreach } } //rest of 1st foreach code here } is there some syntax i can put at the first foreach eg [here] and reference it within the second foreach continue[here]; or something? thanks,
  8. I've got it sorted thanks. In the do_login fucntion I've add a 'error' variable to the SESSION and pick up on this when the focus returns to the index/form. In short, I've learned that using the SESSION to handle messages fed back to the user/web pages is good practice. thanks fo ryou help tho.
  9. yes I am saying that the submit button name element is stating the name of the do_login function.
  10. the function do_login() is taken from the form <input> tag <p><input type='submit' name='do_login' value='Login'/> </p> and the file ot.php which holds it is included in index.php (see the top part of that code) which is called on the form submit, the $_server['request_uri'] equating to index.php <form action='<?php echo $_SERVER['REQUEST_URI']?>' method='post' > as i mentioned, i inherited this code, so the previous coder was either very good at php or has created a spagatti monster ( coder's rule no. 3 - blame the previous coder where ever possible so, i'm still stumped.
  11. Hi there, I follow the logic in what your says but I'm unsure where I'd put that code? In index.php, somewhere round <?php else: ?> <p>Please login below.</p> <?php ot::include_view('login_form')?> <?php endif; ?> or the login_form.php <p><input type='submit' name='do_login' value='Login'/> </p>
  12. Hi, I've inherited some html/php code (lucky me) and it's been years since i've played with it so I'm quite rusty. Anyway, I have a fairly bog standard login process and wish to simply display some text on the login page if the login detail is invalid and possibly log the error to a log file too. here's the index.php file...the login stuff is at the bottom <?php $dir = dirname(__FILE__); require_once "$dir/ot/ot.php"; ot::include_view('header', array('account' => null)) ?> <html> <head> <title>Welcome to ....</title> </head> <body style="font-size: 14pt; font-family=verdana;"> <div><img src="OTLogo1.bmp"/><h1> Welcome to ...</h1> </div> <?php if (!empty($account)): ?> <div style="border-bottom: 1px dotted #AAA; padding-bottom: 2px; margin-bottom: 10px;"> <div style="float: left"> <?php $mtime = (int)@file_get_contents(otDB_DIR."/updated"); $date = date("d/m/Y", $mtime); $time = date("G:i", $mtime); if ($mtime > 0) { echo "Last Updated $date at $time"; } ?> </div> <div style="float: right">Welcome, <?php echo $account->email;?> - <a href="?page=home">Home</a> - <?php ot::include_view('logout_link')?></div> <div style="clear: both"></div> </div> <?php if (ot::is_admin()) { ot::include_view('admin_page'); } else { ot::include_view('user_page'); } ?> <?php else: ?> <p>Please login below.</p> <?php ot::include_view('login_form')?> <?php endif; ?> </body> </html> here's login_form.php <form action='<?php echo $_SERVER['REQUEST_URI']?>' method='post' > <fieldset> <legend>Login</legend> <p>Email:<br/><input type='text' name='email' /></p> <p>Password:<br/><input type='password' name='pwd' /></p> <!-- <p><input type='submit' name='do_login' value='Login' /> <input type='submit' name='do_reset_password' value='Reset Password' /></p> --> <p><input type='submit' name='do_login' value='Login'/> </p> </fieldset> </form> and here's the function do_login (contained in ot.php..a php function file) public static function do_login(&$err="") { $adb = ot::db('account'); $e = self::post('email'); $p = self::post('pwd', '', false); if (self::post('do_login') && $e && $p) { $ao = self::account_from('email', $e); if ($ao) { if (self::validate_login($e, $p, $ao)) { $_SESSION['id'] = $ao->id; return $ao; } } $err = "Invalid email or password"; return false; } } I'm unclear if the do_login fails as to how that ($err) is fed back to the web pages. Any assistance would be greatly appreciated.
×
×
  • 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.