Jump to content


Advanced Member
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by falkencreative

  1. When I look through your code, it looks like the only reason you are getting this error is if this returns false: if($_FILES['image']['name'] != "") So the next step would be to figure out if the $_FILES array is completely empty, and if so, resolve the error. This is a pretty good overview of the essentials regarding what is necessary in order to upload a file: http://www.w3schools.com/php/php_file_upload.asp Are you sure you are using the proper enctype="multipart/form-data" on your form? That is required to upload a file. Is your input for your file named correctly? For example, your input has to be named "image" in order for this to work properly.
  2. OK. So if the user's ID isn't created yet, that's going to be the first step. You'll need to: -- make sure that the user's information is completely valid -- make sure the user's image is a valid type/size (assuming that the registration form includes both the user's information and an image upload -- insert the user's information into the database -- with the info inserted, use http://php.net/manual/en/mysqli.insert-id.php to get the last used id (the student's id) -- upload the image Personally, my suggestion would be to keep the registration process as short and as simple as possible, and save any non-essential information, such as a profile photo, for a "Edit Account" or "Edit Profile" page once they have logged in.
  3. This is the line that sets the final file name, which is currently the student id, and underscore, and the image name. if(move_uploaded_file($userfile_tmp_name, $archive_dir .'/'. $student_id .'_'. $imagename .'.'. $ext)){ If you want to name the image just the student id, you would need to remove the '_'. $imagename . portion. If the filename isn't being saved with the student id currently, you need to make sure that the $student_id value is set. Who is actually doing the uploading? The student themselves? An admin user? If it's the student themselves, do you set a session variable that holds their student ID when they log in? If so, you can set $student_id to the value of that session variable.
  4. Sorry -- I haven't been around here much recently. I'm just about to move cross country (west coast USA to the east coast), so I've been pretty busy/preoccupied. What does your current code do? Are you getting errors? Are you able to upload successfully? If so, what are the files named once the upload process completes?
  5. a path of "images/image.jpg" is relative to the HTML page that you are viewing. So if you're viewing an HTML page and using that path, the web browser expects the images folder to be in the same folder as the HTML file.
  6. Is that a misspelling in the file name? "wite" vs "white"? The code looks fine, so it's probably a spelling or path issue.
  7. If a modal window won't work, really, the only way to get that grown effect you are talking about is to do it with Javascript. I'm not exactly sure what you have in mind, but I'd likely approach it by using jQuery and working with its animation functionality (http://api.jquery.com/animate/).
  8. 1) Maybe I misspoke. I think what I meant to say was not that the MVC pattern itself gets more complicated, but that your overall structure of your application may get more complicated as you advanced, depending on the features and functionality you need. The one big thing that I don't include in my structure, which other more complicated options do, is some sort of pretty URLs and routing. For example, rather than "user.php?id=1&anotherid=2" the system might be set up to use "user/1/2". Doing something like that requires using mod_rewrite and passing all requests through a main index.php file, then having the system figure out what controller needs to be loaded. 2) Frameworks just allow you to build on a solid foundation. You don't have to worry about things like setting up a template object, the models/views/controllers all have specific locations and specific ways of being loaded, there are often common functionality built in (database classes, email classes), and the common codebase allows people to write and extend the framework, and share the code so you can use it as well. It can speed up the process of building an application. This is slightly old by now, but worth a look: http://code.tutsplus.com/tutorials/why-laravel-is-taking-the-php-community-by-storm--pre-52639 3) One central Template object that is created by an init.php file, that all my controllers load at the start. "Model = php classes. You have a php file per class, right?" Yes. "Controllers are mainly functions that use the php classes, create objects and maintain the logic between what we show on the screen and what the user gave us as an input and the DB" Yes, though mine are usually procedural -- no functions needed. Anything that requires a function might go in a shared functions.php file, where the entire application could have access to those functions, or it's a function that should really be part of a model. Depends on the situation. " Is there a reason why you prefer this way and not the way I saw in one of the books, where they build php classes that build a View (for example form class that echo a form, based on different parameters)" I'm not sure what books you are looking at, and I'm not exactly sure how/why they took that approach. But from what you have told me, I wouldn't consider the book's approach MVC. Unless perhaps you had some sort of Form Helper object that helped generate parts of your views?
  9. Everyone handles MVC differently. Possibly the more advanced you are, the more complicated you get... I tend to stick to a relatively simple approach if I'm not using a framework like Laravel. You can see the approach in my videos, but at least in the way I handle it, I tend to structure my application like this: Controllers: these are procedural PHP files, they will usually load a central initialization PHP file of some sort, which may create any standard variables/constants the entire app uses, as well as creating any common objects (perhaps creating a database connection, loading an authorization class if there needs to be login functionality, etc.) In addition, a controller will create objects for any specific pieces just that controller needs. With that in place, the controller will check for any user input (GET data if the URL is created in a specific way), or POST data if there are forms involved, and determine how to proceed or what to display to a user based on this input (or lack of input). Basically, the controllers handle the flow of the application, loading models as necessary, processing user input, and finally displaying the correct view(s) to the user. Models: these are my PHP classes. I usually have a class for every piece of related functionality, and if a class gets too large, it's usually time to refactor the code, possibly into different classes. For example, in your list above, I would say your user class is too large, and you should make sure that functionality related to events and gifts are in separate classes. It might be a good idea to create a separate "Friends" class, that handles creation/editing/deletion of relationships between users. I tend to have a "Template" object, which helps manage and control my views. It can perform common functionality, like storing data that needs to be passed to a view, storing temporary data (for example, alert or error messages), and displaying the views themselves. For example, I might have a line in my controller: $Template->save_data('name', 'value'); $Template->display('users/edit', 'public'); The first line would save a specific piece of data to the $Template object. The data is stored in an array, and can be retrieved later by a view by looking in the array for the array key "name". The second line would instruct the template object to display a view file, edit.php, within the "users" folder, using the "public" template. Templates allow me to save common areas of a website, such as headers and footers, so perhaps the "public" template would include a public header/footer, for regular visitors, whereas a "private" header and footer might contain information that only should be displayed to logged in users. Views: As I said above, in my approach, views are displayed to a user by calling $Template->display(), which will include() the correct file(s). These view files end in .php, but consist primarily of HTML (I'm assuming CSS and Javascript are stored in separate files, but are linked in the view), with minor bits of PHP to retrieve data from the Template class where appropriate. For example, say you wanted to show a "hello, username" line at the top of the page. Your controller would pass the username to the $Template object with a call to $Template->save_data(), where the Template would temporarily store it in an array. When the view is called, the file would consist primarily of HTML, but it would ask the Template object for that username using a little bit of PHP: ...html here... Hello, <?php $this->get_data('username'); ...html here... I'm using "this", because if your view is included() using the Template object, the application is within the scope of the Template object, and "this" will refer to the "Template" object. The Template object will then check its data array for a piece of data named "username", and either echo it out, or echo nothing out if the variable doesn't exist. I hope that helps get you started?
  10. The correct way to implement a GUI is to use the MVC structure, splitting your code into controllers (handles input from the user, figures out what data to retrieve and what views to display), models (usually an object that includes methods that get/set/edit/delete specific data), and views (anything that needs to be shown to the user -- primarily HTML, with snippets of PHP where appropriate to include data). I would suggest checking out http://www.killervideostore.com/video-courses/php-projects.php, specifically, the "PHP Login with OOP and MVC" series, or do research on MVC online. As long as you aren't using "regular" MySQL, either MySQLi or PDO should be fine.
  11. What have you done so far? The process should be pretty simple. On the page where you want the logo to appear, you need to get the image name for the image from the database, adding on whatever path you need in order for the image to link accurately ("path/to/image.jpg"), then, within the page, you add an image using a regular <img> tag, and insert the correct image path retrieved from the database using PHP.
  12. I'm just saying don't try and use iframes as a replacement for frames. Obviously there are specific use cases for iframes (inserting videos, social feeds, etc.), but I wouldn't use them as a layout tool.
  13. Looks like more of an advertisement for Webydo than anything. It doesn't really motivate me to sign up, because it isn't clear about what signing up will do or how signing up will benefit me.
  14. I would really stay away from frames and iframes as much as possible. That's an outdated approach that has a lot of limitations. Definitely take a look at Andrea's links on PHP includes -- they are quite easy to work with and you don't really need to be a programmer to understand them. The only main catch with PHP is that you do have to be running a PHP server for them to work properly, which either means installing something like WAMP (for Windows) or MAMP (for Mac) if you are doing development on your local computer, or making sure to upload the files to your hosting where you should already have PHP set up.
  15. Looks like a logic problem to me. You're running the query, and saying if there is an error, show the error, otherwise set the $flag to "error". According to your code above, your $flag will never equal success.
  16. I'm sorry, I'm not sure if I understand the problem? If you provided them a URL to directly access their account, that would mean anyone else with the same URL would be able to access their account too? If you want to keep it secure, they will need to enter their username and password.
  17. I'd really just suggest you use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to find instances of the old domain and replace it with the updated localhost version. Yes, the URL is set in two post in the wp options table. But in many cases, there are other paths -- usually links to documents or images -- that will still link to the old URL, and won't change if you just change the options table.
  18. I'm not sure where you are in the process, but see my earlier advice: Wordpress stores the path to the website in two spots in the options table in the database, that will need to be updated. In addition, any links to resources (images, downloads, etc.) will often refer back to the old site. To fix this, I've used both https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ (free) or https://deliciousbrains.com/wp-migrate-db-pro/ (paid) in the past. If your site looks "super wonky", it just means you have more work to do -- likely there are other paths that also need changing.
  19. OK, got your initial problem solved. In your t_login.php template (app/core/templates), you used: <script type="text/css"> whereas it should be: <script type="text/javascript"> This causes an issue with Javascript, since it isn't sure how to handle the type text/css, and it doesn't understand that the code within that block should be Javascript. You actually posted that code above, but unfortunately I didn't figure it out till I could see the system in action. Once you fix that, Colorbox should start to work for you. However, second issue, that you'll spot as soon as you fix that... you'll run into a "undefined is not a function" javascript error, pointing to line 24 in v_login.php. jQuery depreciated the "live" function I had been using in a couple places in the course at some point after I recorded the series. Instead, later versions of jQuery use "on" (http://api.jquery.com/on/). So make sure in the spots where I use "live" (for example, in v_login.php"), you switch out "live" for "on": So not this: $('#fp_cancel').live('click', function(e){ but use this: $('#fp_cancel').on('click', function(e){ If you run into Javascript errors, that's something you'll want to check for. This is something I went through and fixed in a updated video at the end of the course, showing how to use the latest versions of the various scripts, but unfortunately you'll run into it if you try to use the latest version of jQuery. Hope that helps get you moving again.
  20. Sorry, I was gone for the weekend, so I didn't have the chance to look at this. After understanding your files a bit better, this isn't a CSS issue. Based on these files, the site is displaying as it should -- you have a header.php file, which has the header information, as well as filler content (which I don't think should be there?), you have an index.php page, which is pulling from Wordpress which is loaded by default, and you have the footer.php file. -- I would start by comparing my header.php file with yours. You should see that my header.php page includes less information -- it doesn't include the blog post excerpts, and ends after the main navigation. I discuss the header.php file and integrating our template code into Wordpress in video 23. -- I'm also using front-page.php to control what appears on the home page, which I discuss in video 24. Assuming you have that file in place, you shouldn't ever be using that index.php file in the theme. My best guess is that at some point, you've accidentally included additional code in the header.php file that shouldn't be there. That file should end after the <div class="navigation"></div> section -- it shouldn't include the banner or content sections. I think this extra code is throwing you off, and making you think that things are perhaps more broken than they are?
  21. What is the file name of that middle file? The one that starts: <div class="banner"> <ul> <li><img src="<?php bloginfo('template_directory');?>/images/banner1.jpg" alt=""></li> <li><img src="<?php bloginfo('template_directory');?>/images/banner2.jpg" alt=""></li>
  22. Is there a place where I can see this project live, online? Or can you zip up everything so I can take a look at it? It's probably going to be easier for me to look at the entire project at once -- with a complex project like this, with many moving parts and files that work together, sometimes that's the only way to debug. (I'm going to be gone a lot of this weekend, so if I don't respond, I'll do my best to get back to you on Monday.)
  • Create New...