Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. First of all, PHP and HTML are two separate things altogether. PHP is typically used to generate HTML. No matter what language you use, when you load a page in a web browser it's source will be pure HTML (and/or even JavaScript). In PHP, the way to preserve a session on every page is to call this function before the first time that you use any $_SESSION variable or anything session related. session_start(); There's no "html page" or "php page". There is just a file that a browser reads the best it can depending how the server reads the extension of the file. So, in order to accomplish the problem of "keep my users logged in on an html page", you need to have PHP file that checks for the session's existence and resumes it if it exists. If it doesn't exist, then it starts one. Correct me if I'm wrong, but I get the feeling when you refer to a "php page", you're referring to the extension of the file ..? mypage.html vs mypage.php
  2. From what I understand so far, you're wanting to keep up with car parts, no? I'm not an auto expert or anything, I'm just trying to get a feel for what exactly you're aiming for here. Either you're trying to keep a record of engines, engine parts, and just auto parts in general, and you're wanting to be able to link certain parts to the cars/autos they're available/compatible with,... or, you're just keeping up with a list of cars and what motor(s) they have/had for e.g a car lot where car salesmen sell cars and keep up with the inventory. Or, perhaps, you're working on a use case catered to mechanics who fix cars and want a history of all of the parts this car has every had in its lifetime. Anyway, it'd help to explain what you're trying to accomplish.
  3. Cars contain a motor. Motors do not contain cars. Therefore, put a column for motor in the Cars table and link through the various motor ids.
  4. Yes! Especially since you're not wanting to use JavaScript, it's as simple as putting links to the same php file but with a query parameter for the category. If you'd use JavaScript, you could do some AJAX magic and just change a portion of the page to reflect the category clicked. That's a bit more involved, though.
  5. What? A bit impatient, aren't ya. First, you make a PHP script that grabs all products from a database where the category equals whatever is in the GET parameter in the URL http://mysite.com/products?cat=movies Then, you loop through the results and display them however you want. It's also possible that a product is part of multiple categories. In that case, you'd have a table just for categories, and then another table linking the columns to products, and then the products table. There's really no cut-and-dry answer here. You simply grab the category id or name or whatever identifier you want to use and grab the products from your database based on that category id.
  6. There are a handful of those kinds of pages. Category Listing Page (CLP) Typically, this is more or less what you'd call a homepage for a particular category where you explain what it is, provide pictures of different products in that category, etc... Typically, the CLP might have a few featured products, but doesn't show them all. Then again, it's up to you. A lot of times you'll find videos on this page, or some kind of introduction to the category. Example: https://www.burpee.com/organics/ Product Listing Page (PLP) This is a page listing your products. It's named as a Listing Page because the products are displayed in a list. Example: https://www.burpee.com/herbs/container-herbs/#sz=24&start=0&type=list Product Grid Page (PGP) Whereas, on a product grid page, they are displayed in what you'd described as a matrix. For instance, 5 columns of products, each row containing 5 product squares. Example: https://www.burpee.com/herbs/container-herbs/#sz=24&start=0&type=grid From then on out, you just have your Product Detail Page (PDP) for products that were clicked on the PLP/PGP/CLP
  7. Sounds like you need to layout your design first and come back with code that you've tried already. You did mention that you have a history with PHP, so gives us a PHP problem to solve. I'm not sure what you're asking. Are you asking if your thoughts sound good? Or, are you asking us what kind of effort it sounds like it would take to do such a task? Or, are you just asking how to do it all? So far, all I understand is that you want to show a list of products and filter it by category. You're also not using JavaScript, so you want these links to refresh the page when clicked and load a page with a pretty url like mysite.com/movies using mod_rewrite. It all sounds ... like the fundamentals of an ecommerce website really. List of products, add to cart, checkout, purchase, etc... Yet, you're only focused on the product listing part at this point and are simply asking how a list of products sounds.
  8. Are you talking about filters? Drilling down the list of products depending on things like Color, Brand, whatever..
  9. Yes. It's not only reasonable, it's common practice to do it that way (with mod_rewrite). Off the top of my head, I can't think of any other way to accomplish this.
  10. Seems like you're only real question is whether or not you're going about this the right way. While there isn't a "right" way, per se, to do something, this is probably the most popular way. You didn't provide code, so I assume you've already set things up this way, no?
  11. How are you generating these links?
  12. @Chrisj What have you tried so far. It sounds like you're just grasping for an understanding of how to do what you're wanting to do with no knowledge of how to use the guidance given to you. It's as if you're asking us how to fly a rocket-ship, yet you have no rocket-ship at all. Or, how do I use a book binder without even owning one. There's no substance anymore to your questions. What is hashing? Hashing is when you take an object (a string, an array, a file, etc) and run it through an algorithm that returns a 32 character garbled string of "random" letters and numbers. It's irreversible. Well, there are ways of speculating what the hash came from, but that's an entirely different realm -- security. Anyway, try something first and then come back telling us what you've tried. At that point you should be able to ask a clearer and less broad question.
  13. //Generate the link $normalText = "this is just your average string with words and stuff"; $hashedText = md5($normalText); fopen($hashedTest, 'w'); echo "<a href='validate.php?video={$hashedText}'>Link to the video</a> This generates a file named 06d5f7c7c17f15f1b28374b16c64e38d, and a link to validate.php?video=06d5f7c7c17f15f1b28374b16c64e38d Then, on validate.php, you'd use the concept I put in my last post.
  14. Wherever you generate your link to the video at, you'll need to add a hash to a database. The generated link should pass a GET parameter with the hash. http://mymp4.com?validate.php?video=40f677a45113eb829e345d278b8d1d31 Then, access your database and look for that hash. If it exists, delete it and output the video using the code that's already been provided in this post. That's probably the most minimalist way that I can think of. You could just skip the database altogether and store the hash in a txt file that's not publicly accessible. Same concept. Here's an example. In this case, the hash is the name of the file. A video will download the first time, but when you try to access it again with the same link, it fails. <?php $v = $_GET['video'] ?? null; if(file_exists($v)) { unlink($v); header('Content-type: application/mp4'); header('Content-Disposition: inline; filename=video.mp4'); readfile("./mytestvideoo.mp4"); } else http_response_code(404); This isn't secure whatsoever, so I wouldn't just copy and paste this. People could essentially just type in the name of one of your files and it would be deleted.
  15. If you didn't know already, the way you are outputting those values is by the use of what's known as a ternary operator. It generally works like a miniature IF statement. You have a condition clause, a true clause, and a false clause. (condition) ? (what to do if true) : (what to do if false); In your case right now, you're simply checking to see if a value is empty or not, by using PHP's empty function. And, if you look in the manual, you'll see that what the empty() function takes a variable and returns to you a true/false value depending on if the variable is in fact empty or not. Or, in the words of the manual: What you're asking for is how to change that condition to mean "is it greater than zero?" and that's as simple as changing the condition to be $total1 > 0 Essentially making it this $var = $total1 > 0 ? true : false; You're wanting to echo things so using simply true or false in the above example won't work. You'll have to replace those with strings. echo $total1 > 0 ? "greater than zero" : "not greater than zero";
  16. It is indeed more challenging than HTML! HTML is a markup language (hence the 'ML' in the abbreviation), PHP is a server-side programming language. Hopefully you learn something here to help you meet your goals. Welcome to PHPFreaks!
  17. Go Barand! Your SQL kung fu has always amazed me, motivated me, and also intimidated me I've actually "liked" several of your posts as well.
  18. In order to answer that, we'd need the actual questions wouldn't we? Why are you tutoring him/her then?
  19. Is, uh... Is that all you got? Each record of what? Care to elaborate quite a bit more?
  20. I can't wait. This is finally happening.
  21. Care to provide a link to the a working application. Otherwise, we can only take shots in the dark. At least provide a screenshot and/or CSS, because this is probably more of a CSS problem than a JS problem.
  22. It's pretty simple really. You just follow this migration guide that's provided in the PHP.net manual http://php.net/manual/en/migration70.php Generally though, unless you've created something so complicated that it's way above average in its composition, it'll be a pretty smooth transition. Mainly, for your most basic PHP7 compatibility check, you'll just make a list of all the functions that you are using in your code, and check each one against what they show as compatible in the manual. For instance, let's look at the isset() function. The manual says at the top that it's available with PPHP 4, PHP 5, and PHP 7. The most important thing you need to make sure of is that you're aware of any changes to functions. Regardless, PHP will give you the error messages you'll need to ask a proper and less broad question.
  23. You could set a session/cookie variable value with a boolean. Like, iniitated_payment. Set to true on click of successful submission (no form errors) and only allow logic to occur when that cookie's value is false. If your payment engine throws an error, then set it back the cookie back to false... or whatever. Several things you could do; it's your UX.
  24. Unless you're just dead set on reinventing the wheel, there are plenty of free resources out there that have to do with countries, analytics, interactivity.. For example http://freehtml5maps.com/free-responsive-html5-usa-map/
  25. A quick fix would be to just strip everything before the ? Add this snippet of code, just above this line // Strip out the query params section $source = explode('?', $node->display_src)[0]); $rss_feed .= '<description><![CDATA[<img src="'.$source.'" />]]></description><guid>https://instagram.com/p/'.$node->code.'/</guid></item>';
×
×
  • 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.