Jump to content

cpd

Members
  • Posts

    883
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by cpd

  1. That's quite an old script you've found somewhere. The ereg() function is deprecated as of PHP 5.3.0 and I'd like to think the version your using is more current, perhaps not though. Instead of sanitising the website (which is wrong in its current state) and email why not validate them using the preg_match function and error if false; its normally better to define what is allowed than remove everything that's not or test for everything that's not. I'd imagine the ereg is causing problems so get it changed to preg_match.
  2. @wotw - Why have you used a switch statement with a single case? An if statement is a better control flow statement to use and you've actually done that hen setting the $case variable. I wouldn't real_escape the password either. Just hash it using an appropriate method (suggest PHPass) and query the database with it.
  3. Personally, I've no idea what "it leaves the variables empty" means either. All you've said is you tried someone's suggestion and it didn't work giving incomplete code as your example. Explain clearly and fully exactly what you've done and what errors your experiencing so people can give you a straight answer instead of beating around the bush.
  4. <script language="javascript" type="text/javascript"> function sumItem(item){ t = 0 for(i = 1; i <= 3; i++) t+= (document.getElementById(item+"_"+i).value * 1); document.getElementById(item+"_total").value = t; return t; // or true after testing } function totalscore(){ var T = sumItem('chip') + sumItem('pitch') + sumItem('roll'); document.getElementById("total_score").value = T; return false; // or true after testing } </script> Although I'd probably split up the value change from the actual summation as its more logical. There's probably an easier way to do it as well but I'm only thinking about your specific needs. What I've offered isn't particularly extensible either but never the less.
  5. cpd

    Loop

    Unfortunately not unless you hack the Category::get_category() method to return the Category object itself; not a particularly good idea though. What's the problem with using the 0 index?
  6. Define "it does not work". Have you taken any steps to find out why; otherwise known as debugging?
  7. Extremely bad practice. A user can edit the Javascript or disable Javascript thus allowing them to submit anything, always have server-side validation. I think the OP is simply asking how to relay error messages back to a submission page from a processing page. Your thoughts on using $_SESSIONS is bang on. You can set an error message using sessions and retrieve it after you've redirected to the form page.
  8. Look up the terms instantiation, joining tables, classes, methods and method visibility. Once you understand all of them re-write your question because it makes absolutely no sense at the moment.
  9. No not really; the theory behind sessions is relatively simple and to the best of my knowledge there aren't any bugs. Its likely your logic is messed up. Why don't you abstract the problem into a simplified example and get it working, then integrate that example with your actual code.
  10. I just ran your code and it runs fine for me. Does exactly what I expect it to do so I'm now confused as to what you mean.
  11. http://en.wikipedia.org/wiki/RC4 Explains it very well with a PHP example. You've just gotta be bothered to read it. Not sure how many VB.NET programmers are on here but PHP being an open source language and this forum primarily for PHP I'd imagine very few in comparison to the amount of active members.
  12. cpd

    Hello!

    Hey, welcome to the forums and I hope we can assist you in your projects where you get stuck.
  13. I don't want to put down what Jessica has recommended because they are valid topics to look up but Pagination itself is a fairly basic task that requires simple PHP syntax. I wouldn't research "pagination" but instead perhaps use it as a method for learning PHP, or rather basic programming skills. Try not to concentrate on learning how to write specific systems/tasks but instead use them to learn PHP syntax, basic control flow statements, loops etc so you can then apply it to any scenario. Research programming control flow e.g. if statements; loops e.g. a for loop; arrays; what a constant is; classes and objects and much more. Choose a task, such as pagination, and try to do it using what you've found.
  14. Your hierarchy is complete nonsense. You've written, in English: "CatClass is a ConnectClass.". This is because you've extended the CatClass to the ConnectClass but in reality a cat has absolutely nothing to do with a database connection. Further more you've ploughed a shed load of logic into single methods; you've included data retrieval and processing all in one method which doesn't make sense especially considering the name of your method. Consider separating your logic into parts e.g. a Database class can have methods such as __construct() (that creates the connection upon instantiation), getConnection(), selectDatabase() and so on. This can be instantiated and passed to the Cat class via a constructor. Plus the points above regarding the return statement and finally, you don't need to put a "Class" suffix after every class. You can't instantiated anything other than concrete classes so its unnecessary effort.
  15. No you can't. Read the php.net website where I think you'll find your use of blow_fish is causing crypt to fail and return a salt.
  16. Confirm your input tag names are correct in your live HTML. If that fails debug each condition of your first if statement individually to see which condition it fails on.
  17. $_SERVER['PHP_SELF'] can be used to get the current page.
  18. Your question isn't clear. You've written two separate questions and not given a context in which your asking them. Provide both and you'll get a far better response.
  19. Depends how the search is set up. A blog search could retrieve matches on slugs and tags of posts. A website search can retrieve either titles based on slugs or scan entire page content (a little too much for me). You could cache previous searches and return the results of that search when someone else runs it. There's loads of methods that can be used to search websites. Ultimately you have a search term and content in a database; the database could be anything from MySQL to a text file. The algorithm used to gather results varies from one specification to the next. http://en.wikipedia..../Clean_URL#Slug
  20. Your control flow is up-the-creek. You need to review your if statements because your final else if tests if $source has been set BUT its included in the control flow that sets the $source variable therefore, if $source gets set it will never make it to the final else if, it'll skip over it.
  21. A name/address app is a good thing to start with. Gets you understanding basic PHP syntax and database interaction. Allows you to understand a little bit of design work and can be developed into something more advanced. The most simple form is storing somebodies name and address only, which can be progressed to handling more information such as contact details an "other information". You can then go further and break into object-orientation, AJAX, multiple persons details at once, searching your database, creating an authentication system and so on. Any one task/project can be as advanced or as simple as you want it to be and usually depends on the specification.
  22. Your signature password hash seems pretty solid but I don't know why you haven't forced the parameter; that seems like a flaw to me. Out of curiosity why do you lop of the first 12 characters from the final string?
  23. Of course you would. If a method or function has compulsory parameters you must supply them regardless of where you're calling it from.
  24. Review your variables, in particular wherever you've attempted to use $_FILES. You're also missing an input field of type "file" which is used to create the array the $_FILES variable points to. There's absolutely no need to go and use Javascript for this either unless you want to create a Javascript uploader. http://goo.gl/W9q8B
  25. The MVC architecture is the theory behind what your trying to do. There are frameworks available such as CakePHP and CodeIgniter that use an MVC architecture and allow you to separate your logic.
×
×
  • 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.