Jump to content

kee2ka4

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kee2ka4's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey Guys, I am fixing someone else's code, so please bear with me on this one. Basically the site has an application form and once the user has submitted the form, they get an automated email with an induction date, and the date is taken from the admin panel where the admin user puts in the date and time and number of applicants. So basically the if the admin user puts in Date: 23th Sept 2011 Time: 9:30 Number of Applicants: 30, the next 30 successfull applicants will get that date and time. The problem with the code is that now whenever the user fills in the application and their application is successfull, they are getting an induction date of Thursday, 1 January 1970 and no time. I am not sure why this happens if someone could point me in the right direction. Here is the snipet of the code where it prints out the date: Your Induction date is <?php echo (date("l, j F Y", strtotime($array_result_ind['date'])))." at ".$array_result_ind['hour'];?> The code at the top of the page is: <?php //include('browser_redirect.php'); //Start session and page session_start(); $induction = isset($_GET['id'])?$_GET['id']:''; $_SESSION['change_ind_date_app_ID'] = $induction; $db_leafletj_jobs = mysql_connect("localhost", "leafletj_jobs", "t10872") or die(mysql_error()); $sel_leafletj_jobs = mysql_select_db("leafletj_jobs") or die(mysql_error()); $query_str = "SELECT applicants.id, applicants.unique_ref, applicants.app_date, applicants.fname, applicants.surname, applicants.ind_date, applicants.ind_ord_no, inductions.date, inductions.hour FROM (applicants JOIN inductions ON (applicants.ind_date = inductions.date)) WHERE applicants.id=".$induction; $result_ind = mysql_query($query_str, $db_leafletj_jobs) or die(mysql_error()); //$count = mysql_num_rows($result_ind); $array_result_ind = mysql_fetch_array($result_ind, MYSQL_BOTH); ?> Also the database for the induction date and time is blank. I haven't designed the application so I am a little lost. I the system was all working a couple of weeks ago but now all of a sudden it prints out that 1970 date with no time. Is this a quick fix? Thanks, Ken
  2. thanks for your reply! The regex rule you defined its fine but without the ":" right at the end. I just need to validate the correct format of HH:MM so 24:00 or 00:00 both are correct time values. Thanks, K
  3. Hey Guys, I am a php newbie and need some help to define a regular express rule that would match the time without the am/pm, so the following formates are all true: 9:00 09:00 22:30 23:59 00:00 etc Any directions here... Thanks, Ket
  4. Hey Peeps, What is the best way to access the session id of a logged in user in the header.ctp file which is in the views/element directory. Basically I have a link called My Account in the header file, and I want to display the logged In user info, once the user logs in. I have the following link in the code: <li><?php echo $html->link('My Account', '/users/view/'); ?></li> But I want to pass the logged in user id in the view? I have included the following var $helpers = array('Session'); in the app_helper file but don't know how to get the session id and pass it to the view. Thanks, Ket
  5. Hey guys, I am a newbie in cakePHP and need some help. I have the following code in the add() function of the invoices_controller: function add() { if (!empty($this->data)) { $this->Invoice->create(); if ($this->Invoice->save($this->data)) { $this->Session->setFlash(__('The Invoice has been saved', true), 'success'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The Invoice could not be saved. Please, try again.', true)); } } } The data is collected from the form in the add view, but I also have a field called "TransactionNum" which needs to store a random generated Number along with the id generated after adding a new record in the database. So say the add(), successfully added the following record: invoice.id = 12, I want to immediately update the TransactionNum with "random number + id" to give it a unique transaction number. Any Ideas?
  6. Hey Guys, I am a newbie in cakephp and wanted some guidance in the model associations before I bake the application. I have identified three entities called Users, Assessors and Invoices but couldn't figure out the correct associations since their logic is a lill different. Here is a brief summary of the web app: 1. Users login to the system and can search for Assessors. Users can select an Assessor and can only select one Assessor. If they want to select another Assessor then they need to first remove their current Assessor. Once the user selects an Assessor, their selected Assessor can create an Invoice that the user can view. Users can have multiple Invoices created by their selected Assessor. 2. Assessor’s can login to the system and view list of users that have selected them. They can create Invoices for their users. So Assessor can create zero or many invoices for their users. I have done some research on model associations and was thinking of using the one to one relationship where dependence is equal to "False" on Users and Assessors so: User has one Assessor but that would make the belongsTo association as a natural complement to the hasOne, so Assessor belongsTo Users - this is not necessarily true since an Assessor many not have any users or a User may not have any Assessor. Can someone provide me with some light here, I am confused :-) I think I am clear with the association of Invoices with Users and Assessors, which is Users has many Invoices Assessors has many Invoices Invoices belong to Users Invoices belong to Assessors Correct me if I am wrong but I am not very clear on what association to use between Users and Assessors? Thanks, Ket
  7. Ah.. thanks man I get it.. i changed it to 6 at the end.. Thanks man :-)
  8. Hey peeps, I have the following regular expression rule, that validates the email address: 'email' => '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,4}$/', But when I input test@test.com it passes but when I input test@test.co.uk it fails. Is my regular expression incorrect? Could anyone plz show me some light here.. Thanks :-)
  9. Hey peeps, I use two functions called 1. element_value($error, $row, $param) that returns the correct value for a form element! Here is the code: /** * returns the correct value for our form element * @param bool $error * @param string $row * @param string $param * @return string */ function element_value($error, $row, $param) { if ($error){ return ''; } if ($row) { return $row; } if ($param) { return $param; } return ''; } and 2. error_msg($error, $msg) which returns the error message of a form element if there is an error. Here is the code: function error_msg($error, $msg) { if($error) { return $msg; } return ''; } My question is, this works fine with an input box or a text box field but I cannot make it to work for a dropdown. So if I don't make a selection for a dropdown, it does not echo out the error. Here is my form element... Code for the input box, this validates correctly! div class="elementPost"> <label for="title" class="smlText"><strong>Title: <img src="/public/images/required.gif" width="8" height="8" /> </strong><span class="helpMsg"> <?php echo error_msg($errors['title'], 'Oops! Title must be atleast 5 chars.'); ?></span></label> <br/> <input class="textpost" type="text" value="<?php echo element_value($errors['title'], $postAd['title'], $params['postAd']['title']); ?>" name="postAd[title]" onFocus="javascript:toggleMsg('msg-2')" onBlur="javascript:toggleMsg('msg-2')"/> <span id="msg-2" class="smallmsg" style="visibility:hidden;">Minimum 5 characters </span> </div> Form element for the dropdown - this doesnt work, it doesn't give out the error when I do not make a selection in the dropdown: <div class="elementPost"> <label for="email" class="smlText"><strong>Country: <img src="/public/images/required.gif" width="8" height="8" /> </strong><span class="helpMsg"> <?php echo error_msg($errors['cid'], 'Oops! Please select a Country.'); ?></span></label> <br/> <select name="postAd[cid]"> <option value="">Select Country</option> <?php $countryList = getCountryList(); foreach($countryList as $countryName): ?> <option value="<?php echo element_value($errors['cid'], $countryName['cid'], $params['postAd']['cid']); ?>" <?php echo (($countryName['cid'] == $params['postAd']['cid']) ? ' selected="selected"' : null) ?>><?php echo $countryName['country_name'] ?></option> <?php endforeach; ?> </select> </div> Any Ideasss?
  10. Hey peeps, I have a form that has a dropdown of the list of all the countries. What is the best way to automatically select a country based on the users IP(location). Has anyone done something similar.. plz guide me in the right direction... Thanks, Ket
  11. Any reason why using Regular expression is not effective? How do I use strlen in this case. Thanks for your reply
  12. I have the following regular expression for the body field which is a Textbox in a Form, that accept minimum 15 characters and maximum 2000 characters: $post_validation = array('body' => '/^.{15,2000}$/'); The issue I have having is, whenever I paste a large text from another website into my textbox that is below the 2000 characters, the $post_validation returns an error. I can't make out why this happens. Has anyone faced a similar problem? Thanks, Ket
  13. Hey peeps, I have a question with regards to loading my site from a sub folder. At the moment, I place my entire site in the www folder provided by my hosting company and when i type my url, my site works fine. But I want to place my site in a folder within www and load my site from there. So for example, if I place my site in a folder called siteone within www and when I type in my url, say www.domain.com, I want the site to load. I am not sure how to do that. Can someone plz point me in the right direction. Thanks, Ket
  14. Hi guys, just to update I have sorted out the problem. Bascially it was my htaccess file that was the root of the problem.
  15. Hey peeps, I have a question as why Internet explorer never displays my error messages the frist time I run my code and always displays it the second time. I am using $_SESSION['flash']['warning'] to displays messages. Here is the breakdown of my code. I am using the function below to display error messages: function flash_warning($msg) { if(!$msg) { return false; } $_SESSION['flash']['warning'] = $msg; return true; } In my controller file I have the following code that simply decides if the condition in false then display the message. if(!formSent($params)) {flash_warning("Sorry your message cannot be sent");} In the view file, I display the error mesage(if there is any) using a simple if statement: <?php if($_SESSION['flash']['warning']) { ?> <span class="helpMsg"><?php echo $_SESSION['flash']['warning']; ?></span> The above code works fine the with Firefox but with Internet Explorer it never displays the error message the frist time and always displays it the second time. Can anyone please guide me why this happens? Thanks, Zub
×
×
  • 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.