Jump to content

garbagedigger

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

garbagedigger's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Interesting. So from what I gather, it's better to build validation for solving specific situations right? If that is the case, is it almost better to build separate validator classes which represent specific situations and decouple the validation methods from the model? I still don't understand if it's bad practice to do the validation inside the factory methods like factory->getUsers(input data) or factory->updateUsers(input data) or where in the process the validation should really start. I was jut reading one of Martin's articles on mappers. http://martinfowler.com/eaaCatalog/dataMapper.html. He definitely has some good things to say about application architecture. It's a great article for describing ways of decoupling the database from the model.
  2. So I am working on an MVC application where the controller methods instantiate a factory that is suppose to return a model. In this case, the factory methods do some kind of work with a database or API to save/get/ data which then is placed inside a model and returned by the method. So lets say I have a factory method called createUser(email, password); Now I am going to call this method in the controller. I want my controller lean and mean and not fat! The model can be fat but NOT the controller and so my methods for validation at the moment are inside the model. Where do I call this validation? Inside the controller before the factory? Inside the createUser() method in the factory before it does it's database and api work to return a model??? Where?!? Here are two scenarios that come to mind: -Instantiate the User model inside the controller method before the factory and validate the input data. If it returns without any problems, send it to the factory to return a model of the User with the newly created data. -Instantiate the factory, call createUser(input data) and inside the create user method, do the model validation first before getting/saving the data to an API or database? If the validation fails in the createUser() method, return a model with error messages and any of the bad data. If their are no validation problems, return a model.
  3. I think what is going on is that you are not returning an associative array in your mysql query. I think it might look like this: $result = mysqli_query($dbconnect, "SELECT ingredients FROM recipes"); $result = mysql_fetch_assoc($result); $result = array_unique($result); foreach ($result as $value) { echo "<li>$value</li>"; } Here's the manual: http://php.net/manua...fetch-assoc.php
  4. Maybe... It would need someone to administer the messages for application and application services. This admin could push the messages out and my application would listen for messages and show them to the client who is signed into the application (for application messages). The service that the client would have actively open in their browser would know to get messages based on the service. I would want this setup so messages would go away when the client selects a close button next to the message in the ui (maybe it makes an ajax request and updates the db to not show the message for that user anymore). Some messages might be more user specific and only appear based on the actions they have taken within the application they are using. These sort of messages wouldn't really need much administration. For example, maybe there would be a message telling newly signed up users to register their display name because this process wasn't required during registration. So maybe this whole thing is a custom solution that I have to completely build myself rather than using a message cue and some custom code in my application? I still don't feel like I am getting a clear idea looking at message cues but perhaps they would be useful for application and application service messages meant to go to the client.
  5. you are using $_REQUEST with a key (myLocation) that is not set. $_REQUEST looks for a post, get or cookie and you have not set this location key and it's value as a cookie or passed it in a post or get request. That is why you don't get anything back. So there are a few ways to address this. I will show you the GET way. simply add this line of code to whatever php page is serving up the link: echo '<a href="locations-page.php?myLocation='.urlencode('philadelphia-pa-19128').'">Philadelphia, PA 19128</a>'; Inside your locations-page.php add the following line: echo urldecode($_REQUEST['myLocation']); That should take care of it. You are sending the myLocation as a url param (?myLocation=) and getting the data based on the key 'myLocation'. You can also use $_GET to do the same thing.
  6. So on my spare time, I am architecting a PHP service oriented application, which uses web services. I want to architect a solution for delivering global, service, and user specific messages in the application. These type of messages would appear to the client after they have logged in. They would obviously be maintained at a database level but I need to build some pretty little php classes that can grab the data and display it in my application to the client if messages exist. Is there a name for something like this? I am struggling on how to best design this solution so it is flexible and it would be nice to gain perspective on this topic. I just don't know what to look for and often times my results are related to designing a message system where clients of an application can communicate to each other, which is what I am NOT looking for.
  7. I have this reg expression that uses 'ereg' so I tried to update it to use 'preg_match' like below: if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) But I was given the following error: Warning: preg_match() [function.preg-match]: Unknown modifier '=' in So I figured I need to tell PHP not to treat those characters otherwise seen as modifiers in the reg. expression by using 'preg_match_all': if (!preg_match_all("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) But then I was given this error: Warning: preg_match_all() expects at least 3 parameters, 2 given Any Advice? Thanks!
  8. I have a ajax/php driven website and I want to setup a link which uses dompdf. I want to click on the link to convert the current page being viewed to pdf. The current code that came with dompdf has a link feature like this except it looks for the physical webpage on the server and converts it to pdf and not the finished webpage being viewed on your web browser Here is the original code for the link which pulls the physical webpage and inputs it to dompdf for pdf conversion: <?php $test_files = glob(dirname(__FILE__) . "/test/*.{html,php}", GLOB_BRACE); $dompdf = dirname(dirname($_SERVER["PHP_SELF"])) . "dompdf.php?base_path=" . rawurlencode("www/test/"); foreach ( $test_files as $file ) { $file = basename($file); $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; echo "<li style=\"list-style-image: url('$arrow');\">\n"; echo $file; echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode($file) . "\">PDF</a>]\n"; echo "</li>\n"; } ?> I took and modified that code to use $_server[“php_self"] <?php $test_files = glob(dirname($_SERVER["PHP_SELF"]), GLOB_BRACE); $dompdf = dirname(dirname($_SERVER["PHP_SELF"])) . "dompdf.php?base_path=" . rawurlencode($_SERVER["PHP_SELF"]); foreach ( $test_files as $file ) { $file = basename($file); $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; echo "<li style=\"list-style-image: url('$arrow');\">\n"; echo $file; echo " [<a class=\"button\" target=\"blank\" href=\"$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode($file) . "\">PDF</a>]\n"; echo "</li>\n"; } ?> After doing that, I get this error message: DOMPDF_Exception: Requested HTML document contains no data If I take rawurlencode on my modified code and tell it to use the url like this: rawurlencode("http://local.example.com"); It converts and prints a pdf but it is the site's main page before you are logged in which is useless if you are logged in. I need to somehow trick it to encode and print the ajax/php driven view my browser is displaying. Is that even possible? Iam guessing that I need to replace rawurlencode with something else and still use php_self. Let me know if you need more information or details. Thanks!
  9. That is a pretty neat trick with text-transform in CSS but unfortunately it doesn't prevent from making any characters after the first character upper case. So someone could still write: DsdfDFS with the characters after the first character in uppercase. I only want the first character to be upper case and the following characters to remain lowercase. BUT...I did find a fix on my own for this problem. For some reason it works it when I add 'strtolower' which I realized I needed anyway to make the remaining characters lowercase. Crazy! Here is the new example: $Data['FName'] = ucwords(strtolower($_POST['FirstName'])); $Data['LName'] = ucwords(strtolower($_POST['LastName'])); $Data['Address1'] = ucwords(strtolower($_POST['Address1'])); $Data['Address2'] = ucwords(strtolower($_POST['Address2']));
  10. I have a registration page I am creating which passes Ajax data from a form to the function ProcessSignUpData. I am trying to use ucwords on this function for the name, address and city form fields and it isn't working. Any Suggestions what be greatly appreciated! If I am not providing enough information, please let me know! Here is what the code looks like: if ($_POST['ProcessSignUpData']) { usleep(3500000); unset($Data); $Data['OldCardNbr'] = substr(preg_replace("/[^0-9]*/", "", $_POST['SavingsClub']), -; $Data['FName'] = ucwords($_POST['FirstName']); $Data['LName'] = ucwords($_POST['LastName']); $Data['Address1'] = ucwords($_POST['Address1']); $Data['Address2'] = ucwords($_POST['Address2']); $Data['City'] = ucwords($_POST['City']); $Data['State'] = $_POST['State']; $Data['Zip'] = preg_replace("/[^0-9]*/", "", $_POST['ZipCode']); if (ValidateEMail($_POST['EMail'])) $Data['EmailAddr'] = $_POST['EMail']; $Data['HPhone'] = phone_format($_POST['HomePhone']); $Data['WPhone'] = phone_format($_POST['MobilePhone']); $Data['BirthYear'] = preg_replace("/[^0-9]*/", "", $_POST['BirthYear']); $Data['BirthMo'] = preg_replace("/[^0-9]*/", "", $_POST['BirthMonth']); $Data['Sex'] = preg_replace("/[^MF]*/", "", $_POST['Gender']); $NumberOfCards = preg_replace("/[^0-9]*/", "", $_POST['NumberOfCards']); if ($Data['FName'] && $Data['LName'] && $Data['Address1'] && $Data['City'] && $Data['Zip']) { // Check to see if the person is already signed up with a new card number (dupliate signup check) $IsDup = FALSE; // First check database SCVL1 $My->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `member` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My->fetchArray()); } // Then check database SCVL3 if no dup found in SCVL1 if ($IsDup === FALSE) { $My3->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `tblmember` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My3->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My3->fetchArray()); } } // Show an error if a dup was found if ($IsDup === TRUE) {
  11. THANKS YO! I also found out the name of the picture text verification thing. It is called "captcha." Here is some freely available code for it in case there are others who are interested: http://www.ejeliot.com/pages/2 I have started the http://www.php-mysql-tutorial.com/ on registration. It is very basic but it does a good simple job at breaking it down.
  12. I'm working on some sites and I want to be able to make it so users can register and have accounts at mysite. Ideally, I would like to create a system very similar to the current one at this site. It would be nice to have a picture text verification, or some kind of confirmation by email or both unless that is being too secure against fake sign ups. Where would one start on this? I have been reading mysql for sometime and I have a good grasp of creating relational databases. I also know how to use css. I have read some C and fooled around with some simple php scripts. I just need to figure out the code involved in creating a user registration page. Do I need to go to school for it? Are there any good books that run you through it? Thanks!@
×
×
  • 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.