Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by sKunKbad

  1. In your model, school should be school_id, and subject should be subject_id <?php class User extends CI_Model { public function add_user($data) { $data = array( 'username' => $data['username'], 'name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'user_type' => $data['user_type'], 'phone_number' => $data['phone_number'], 'subject_id' => empty($data['subject_id']) ? null : $data['subject_id'], 'school_id' => empty($data['school_id']) ? null : $data['school_id'] ); $this->db->insert('users', $data); } } ?>
  2. It looks like the products are in a list with add to cart buttons. It seems you figured it out, no?
  3. It looks like you have not defined APP_BASE_PATH, or if that is an actual path, the file doesn't exist.
  4. You could just encrypt/decrypt a value stored in a cookie, but sessions is the easiest solution because it keeps the value on the server.
  5. You would need to include title.php, not use file_get_contents.
  6. Since you have no experience with PHP, it's unlikely that you will be able to get very far, even with some help. The Yahoo weather feed is XML, and you would parse it with PHP's SimpleXML class. If you search Google or Yahoo for "Yahoo weather SimpleXML", you'll probably find some examples, as this feed is pretty popular.
  7. I'd like to query the database for appointments that were made, but only the last day that they were made. The last day might not be today or yesterday, but it could be today or yesterday. I'd like to not have to do a separate query to determine this date. Can this be done? I'm already sorting the query by another column in case it matters. Any help is appreciated.
  8. I figured it out. I just needed to use mkdir for the dirs that didn't exist.
  9. A lot of times I will need to use Wordpress on sites that are on shared hosting. FTPing all of the files up to the server can take a long time, so I thought I'd just make a script to get the zip from wordpress.org, and then unpack it. I can use PHP's ZipArchive class to do this, BUT I want to remove the outermost directory called "wordpress", and that's where I've run into some trouble. Files that are in subdirectories of "wordpress" do not get copied, and I get errors that the files don't exist. I'd appreciate any help, or if there is a better way, please suggest. class WP_unpack { public function __construct() { // If file not already downloaded, download it if( ! file_exists( __DIR__ . '/wp.zip') ) { file_put_contents( __DIR__ . '/wp.zip', file_get_contents('http://wordpress.org/latest.zip') ); } // Open up the zip $zip = new ZipArchive; if( $zip->open( __DIR__ . '/wp.zip') ) { for( $i = 0; $i < $zip->numFiles; $i++ ) { $filename = $zip->getNameIndex($i); $fileinfo = pathinfo($filename); if( $filename != 'wordpress/' ) { // Remove wordpress/ from the beginning of the filename if( 0 === strpos( $filename, 'wordpress/' ) && isset( $fileinfo['extension'] ) ) { $new_filename = substr($filename, strlen('wordpress/')).''; copy( 'zip://' . __DIR__ . '/wp.zip#' . $filename, __DIR__ . '/' . $new_filename ); } } } $zip->close(); echo 'success'; } else { echo 'fail'; } } } new WP_unpack();
  10. It looks like the plugin is active in development. Have you considered messaging the plugin authors to see if they would implement the feature?
  11. I think you should just go for SF2. Being that you have programming experience, you'll do fine. A lot of the other frameworks borrow code from SF2, so it must be good, right? I use my own proprietary framework, but if I didn't, I'd use SF2.
  12. My personal opinion is that you should never define a constant that isn't absolutely going to be the same value throughout the application, because it is global in scope. For instance, even your DB connection params might change, because it is possible (and common) to connect to more than one database. I'll usually define a WEBSITE_NAME and an ENVIRONMENT constant. I usually define a constant that is the path to the front controller (index.php). It's pretty common to store most of the website configuration in config files. Check out most of the popular PHP frameworks and you'll usually see them stored in arrays.
  13. I'm way overdue for a vacation.

  14. What happens when you check the post array like this: echo '<pre>' . print_r( $_POST, TRUE ) . '</pre>';
  15. You've used password_hash in the context of the MySQL query, but password_hash is a PHP function. You'll need to close the query string, concatenate it with your php function, then concatenate that with the remainder of your query string. Hope that makes sense.
  16. You can't use a standard function inside a class like that. What I mean is, the call to the function isn't inside a method. If you want it to run automatically, put the call inside a __construct method.
  17. Time changes this weekend. Ahhhhhhhhh!

  18. If you want to store the firstnames as an array, you can use php's serialize function. This isn't recommended though. Ideally you would adhere to best practices concerning database normalization.
  19. I use ip2country too. You are way better off using the bin file. It is super fast for queries.
  20. You are on the path to destruction with this login script. You're not validating to escaping the variables that are being placed right into the query. You're also not hashing your passwords. Take a look at PDO or mysqli prepared statements, and hashing passwords is an absolute must. Also, unless you plan to take a long journey to learn all the ins and outs of authentication, you're better off using somebody elses code. I suggest a framework like Laravel, which has built in auth. Even on sites that are very small, you compromise your user's personal email accounts and more when you use weak authentication.
  21. Looking at the comments on the php.net page for is_callable, it would seem that is_callable didn't take visibility into account, but when I was playing around with it, it seems like it does: <?php class Foo { public function __construct(){echo 'foo';} public function a(){echo 'a';} protected function b(){echo 'b';} private function c(){echo 'c';} public function e(){echo 'e';} protected function f(){echo 'f';} } $foo = new Foo; $methods = ['__construct','a','b','c','e','f']; foreach( $methods as $method ){ if( is_callable( [ $foo, $method ] ) && strpos( $method, '_' ) !== 0 ){ call_user_func( [ $foo, $method ] ); } } echo ' should be fooae'; Did it change at some point? I've got a simple router that I'm using, and want to ensure that browsing to protected or private methods are blocked. Code similar to above would be easy to implement. Am I missing something?
  22. You could use AJAX to send the details of the update (your form submission) to a processing script, which would return the updated data. You would simply replace the current data with the updated data. jQuery makes this really easy, but it can be done using plain JavaScript or nearly any other JS framework.
×
×
  • 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.