Jump to content

Zane

Administrators
  • Content Count

    4,162
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Zane

  1. I would make students[modules] an array of module objects instead of an associative array with numbers in quotes. var data = { "students": [ { "name": "Eric Smith", "modules": [ { "id": "COMP40003", "name": "Software Development", "result": 80 }, { "id": "COMP40001", "name": "Digital technologies", "result": 71 }, { "id": "COMP40004", "name": "Web Development", "result": 47 }, { "id": "COMP40002", "name": "Networking Concepts and Cyber Security", "result": 0 } ] }, { "name": "Student Two", "modules": [ { "name": "Module 1", "result": 44 }, { "name": "Module 2", "result": 5 }, { "name": "Module 3", "result": 34 } ] } ] }; And then loop through it using the native array function forEach() data.students.forEach(function(i){ console.log(i.name); console.log("======================"); i.modules.forEach(function(j){ console.log(j.name + " " + j.result); }); console.log("======================"); });
  2. Perhaps you should re-phrase your question because, obviously, the solutions given to you aren't what you're looking for, as you've pointed out. If you're simply trying to increment the ticket id/number by one every time a ticket is added to the table, then the above solutions are what you need. From the code you provided, it almost looks as if you're trying to place the current count of tickets purchased at the time of the new ticket insertion. For instance, George buy 5 tickets and at that point in time there had already been 80 tickets sold, so you put 80 + 5 to put in that column. Or, are you just trying to store information in a table all by itself which contains nothing but calculated values that you could have created within the query, but you want to create those values manually? Please, rephrase your question and don't just dismiss legit solutions because you don't think they'll work. Explain why they won't work before you just shrug off the efforts of the volunteering experts here.
  3. PHP has a handy function for this called: is_dir()
  4. OK, so that should involve: A users table, of course, that contains the height and age An attributes table, with a column for the name of the attribute and unit of measure (UOM i.e years). A user_attributes table with a column for user id, and attribute id, attribute's UOM value
  5. So, it sounds like what you're after is custom attributes User A has a hypnotism rate of 45 neurons per second, and a clairvoyance rating of 5 / 10. User B has a rank of 3 of understanding of quantum physics and a shoe size of 25 and a half meters. User C has fourteen years worth of towel folding experience User D can eat twenty three beer battered brauttwerst in 48 seconds. Am I getting closer to what you're talking about?
  6. 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
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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
  12. 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.
  13. Are you talking about filters? Drilling down the list of products depending on things like Color, Brand, whatever..
  14. 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.
  15. 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?
  16. Why not? That's the whole point in having an id attribute, to identify it easily. Instead of having to use textarea[name='LOOKUPADDRESS'] you can use #LOOKUPADDRESS To get you textarea to populate, though, you'll need to listen for the click of the anchor tag, or modify what happens when it's clicked. <a href="#nowhere" id="anchor">Click HERE</a> <textarea id="LOOKUPADDRESS"></textarea> document.getElementById('anchor').onclick(function(arg){ arg.preventDefault(); var t = document.getElementById("LOOKUPADDRESS").innerText = "<?php echo $col; ?>"; }); I haven't tested any of this code, so copy and paste at your own risk.
  17. You lost me at machines hurting you.
  18. Ah, I completely missed that. I do agree with everyone else though.. Why are you not using a framework for this? With jQuery, you can do a POST request as easy as this: jQuery.post('urlpost.php', { 'url':'facebook.com' }); Not only that, but you can add a callback function to do stuff with the data returned. jQuery,.post('urlpost.php', { 'url':'facebook.com' }, function(data){ console.log(data); }); Why go about it in the most antiquated way?
  19. You have to send the parameters with the send() function request.open("POST", "urlpost.php", true); request.send(params);
  20. The extension doesn't even have to be .php either. You could have myfile.notphp instead. It's arbitrary. All you have to do is edit the webserver configuration. <FilesMatch ".+\.ph(ar|p|tml)|.+\.notphp$"> SetHandler application/x-httpd-php </FilesMatch> Obscurity only really draws attention though. I mean, if you're a spy trying to blend in, you're not gonna wear a hat saying "not a spy", hopefully. http://mysite.com/index.notphp
  21. It's been over 10 years since I messed with Authorize.net API. I first used it to allow people to make single secure payments from a web page of mine to a bank account. That's it. Back then, they didn't have all of this fancy new stuff. Therefore, i really don't have any valuable comparisons to give. Also, I do not consider myself to be anything close to an expert (or even intermediate) level of creating secure systems. I ran a mail server about 6 years ago and that was a total nightmare. Literally, as soon as the server went live, it was plagued with bots and whatever else that started using my SMTP server as an open relay and my IP became blacklisted pretty quickly for spam. I google ad nauseum for how to secure this and how to secure that and what the best practices were, but I was in way over my head with absolutely no budget for anything to help me out. After 4 years of trying to maintain a mail server that successfully sent and received mail with no issues (though, there were still issues), I finally was able to convince my boss to switch to a Google Business account and let them handle all of that guff. Mail servers are an absolute nightmare that I wouldn't wish upon my worst enemy. I mean, installing SSL certificates is easier than maintaining a mail server. Anyway, this topic has nothing to do with mail servers. You know, I've never tried to even perform a breach in my life. I've never even tried to breach myself. It's an exhausting realm of web development that I avoid like the plague. Really, what is secure? Unless you're a Fortune 1000 company or something, I doubt you're going to have a hoard of people trying to hack your site; don't flatter yourself. I was a web developer and ran probably the least secure site, in my opinion, but the audience for that site was so minuscule compared to that of large corporations. It's about the same concept as viruses. Most people running a *nix system do not really need to worry about viruses because *nix systems do not take up much of the market share for personal computers. However, Windows is always being probed and poked and molested because it has a gigantic user-base. In any case, Authorize.net seems to have improved pretty much everything they had when I messed with it over a decade ago. Most, if not everything, of what I utilized is gone or deprecated. I mean, I would trust it. At the end of the day, though, the most secure you'll ever be able to make your system is if you cut it off from the net. If it's not on the internet, you really have nothing to worry about. If you're not connected to the internet, you're not going to get any viruses anytime soon. I know that's not an answer, but it's a hard truth to accept. Online banking is really awesome in my opinion, but I know that at any particular time, something could go awry and cause my life hell.
  22. The would remove any risk unless both your database and Authorize.net's database were breached. Fundamentally, yes. It's that easy. How you go about it though is up to you. Authorize.net provides sample PHP scripts for sending and receiving the data. It may look intimidating, but you're essentially just creating a JSON object and sending it to Authorize.net, from which you'll receive a response. In your own database, all you'd need is your usual fields, and then you could add come columns that link it with Authorize.net's customer profile. So, there's you typical user table user_id user_name user_pass You could then add a column for the customer profile id that's generated from Authorize.net user_id user_name user_pass user_authorize_id As for the payment profile, you'd store them in their own table, called say... payment_profiles. It would contain profile_id profile_authorize_id user_id Some people roll their own form of sending data, some people use the official code provided https://github.com/AuthorizeNet/sample-code-php/blob/master/CustomerProfiles/get-customer-profile.php This way, you don't have to hash anything or maintain anything PII related. You'll be able to login to Authorize.net as well and create reports of your customers with Customer Information Manager. ** This is all assuming that you're only using Authorize.net to handle your transactions. If you have other merchants, like Paypal, then you'll need to check out what they have to offer as well.
  23. If you are using Authorize.net, then you can setup Customer Payment Profiles, using their API. You can then store (or relegate) the customer payment profile id to your users table in your database. Then, you don't have to worry about storing credit cards info anywhere. https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile Maintaining reconciliation with Authorize.net customer profiles and your own database/table of users can allow you to do what you're attempting to do. Using the API, you can send a request for the current users list of payment profiles. If there are more than two profiles, then you can write in whatever logic you want in your PHP script, for instance, aborting the chance of a transaction from the user, showing them an error message. Everything you need and more is available in their API.
  24. Could you explain the scenario a bit more? Only two accounts per cardholder. So, a single user can purchase cards, and these are credit cards? It's not so clear what your idea is. Please elaborate. Or maybe, it's a user cannot add more than two cards to their account.
×
×
  • 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.