Jump to content

maxxd

Gurus
  • Posts

    1,718
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by maxxd

  1. It sounds like you're getting what you wanted in the OP - you're triggering the function from a mouse event on a form element. What you do now is up to you - we don't know what your goal is.
  2. Try dumping out $data['products'] like so: dd($data['products']); Make sure there's actually anything there to loop through. You can also add try/catch blocks around the orderProduct and product creation and log any exceptions you catch.
  3. Have you looked into Guzzle? You'll still need to write your own code, but it's certainly easier using Guzzle than using native php cURL.
  4. I'm also a bit confused by the percent width comment - you can use percentage as measurement, but you certainly don't have to.
  5. Use media queries to create rules based on screen size or browser device as requinix suggested. Though admittedly you may have some work ahead of you as WPBakery (as far as I recall - thankfully it's been a while since I've had to deal with its output) has a tendency to overdo it with the built in CSS.
  6. Just a point of clarification, in this case json_decode is returning an object not an array. To access any of the values in the object, call the property key. For instance, to loop through the players you'd do this: foreach($obj->event_match_details as $detail){ echo "{$detail->playerfirstname} {$detail->playerlastname}" }
  7. So you're saying you don't like HTML?
  8. I hope this makes sense - it's how I thought about it a millennia ago when I was learning php - you can mix php and html, but you can't combine them. In other words, as Barand said above, if you want to output html without using the print or echo functionality of php, you need to exit php mode and enter the browser's default mode of html output by using the '?>' php closing tag. By the same regard, if you intend to inject php into your html you need to specifically enter php mode using the '<?php' opening tag. There are obviously exceptions to this (certain templating languages, etc.) but these are things to think about later on - right now don't worry about it. Just make sure all of the php code you're executing within html is contained in the '<?php ?>' tags.
  9. Where is the data coming from? There could be several different reasons why you're not seeing whatever it is you're expecting. Which is a good point - what exactly are you expecting to see?
  10. What you're seeing is the default landing page for Laravel. If you're surfing to http://localhost:8000/ it's matching the '/' route in the web.php file, so it'll render the welcome.blade.php file. If you want to see your questions/* routes you need to request them - go to http://localhost:8000/questions.
  11. First and foremost, don't run the query in a loop. Chances are you can use a join to get a full dataset before you begin your loop. The other benefit of doing this is that your data will more than likely present itself in a way that makes what you're trying to do easier. Can't help you with how to do that as we don't have all the code and what we do have is clearly not the actual code (there's no $sqlb2 for you to loop over in what you've posted).
  12. I take it there's a class called 'frontpage' with a non-static method called 'index'?
  13. maxxd

    Anti XSS

    Does that mean that you've made sure you're using prepared statements, nonces for your CSRF, and proper XSS request headers or do you mean you feel fine altering user input because what you have looks like it's working as it is?
  14. The image tag is the main element in this situation - it's wrapped in a picture tag (the container), and the src elements can be thought of in the same way that media queries are in css. You need to have the img tag in the picture element to actually display the image source as defined by the src elements depending on their media attribute. Basically, in your situation the <img> tag is the only actual element in the structure. The rest of it is conditionals.
  15. If I remember correctly, you need to add the class attribute to the <img> tag. The picture tag is a container, and the source elements replace the inner image tag at the defined breakpoints.
  16. XMLHttpRequest is a bit outdated these days with the rise of the fetch API. That having been said, the fetch API can be a bit rough to wrap one's brain around if you're new to it. Either way, one option is to add an additional parameter to the AJAX calls (for instance, 'ajaxRequest') that isn't set in the normal call expecting a full page refresh. Check for that extra parameter in the processing code and you know how to return the data - either a JSON string of just the data or the entire page. I'm a little brain-fried, so I hope that makes sense...
  17. This is where an MVC-style approach to the server-side code comes in handy. The display logic is in the view, and the controller decides what to return. If the request to the controller is AJAX-based (or POST, in this case) the controller returns JSON-encoded data whereas if it's not, it returns the full compiled HTML.
  18. Whatever you end up doing with the email itself, do yourself a favor and use one of the major libraries instead of php's native mail() function. I'm most familiar with PHPMailer, but I believe laravel uses Symfony Mailer. Either is going to make your like much easier in the long run.
  19. You require_once and use statements need to be outside the function; they're global functions. You can then use the classes inside a function. So, the instance that works, just put everything after require statements into a function and call it normally.
  20. Structure-wise, I agree with mac_gyver. This is really no different than the hotel booking system you were working on before. A single cinema booking can consist of multiple seats, much like a single hotel booking can consist of multiple rooms. Take a step back, think about what you know from past experience, and re-evaluate your current data design; in this case I very much doubt that a "booking" is a single seat.
  21. The ajax call doesn't interact directly with the php - the only time it'll register a failure is when the call itself fails. So if you call a non-existent endpoint or if the server is down, the ajax call will invoke the error method. If however the php can't find the record or there is an error in your code that doesn't halt the execution of said code, there will still be a successful response from the server and the ajax will treat it as a successful response. What typically happens is the php script returns a json-encoded array with a 'success' index that indicates whether or not the php function worked. This is what I meant when I said 'just have php return the status of the call' - add a boolean to the return payload that can tell the javascript if the php failed in a manner that didn't cause a server exception.
  22. Sorry, I was multitasking and therefor distracted earlier (hence my deleted post). I can give you a quick example using the fetch() api though it's been a while since I've used jquery ajax functions so I couldn't get that working - hopefully this'll still give you a nudge in the right direction. Unsolicited opinion; it's worth looking into fetch() or axios() if you want to move beyond jquery. I find them both simpler to use and easier to read (especially axios). Having said that, there's nothing wrong with jquery but it's not something I personally have seen used for new development in a while. html: <form action="" id="my-form"> <input type="text" name="test-1" id="test-1"> <input type="text" name="test-2" id="test-2"> <input type="submit" value="Click me"> </form> javascript: let frm = document.getElementById('my-form'); frm.onsubmit = e => { e.preventDefault(); let dt = new FormData(e.target); dt.append('new-value', 'test-3'); let ret = fetch('/jstest2-handle.php', { method: 'post', body: dt }).then(d => { return d.text(); }).then(ret => { console.log(ret); }); } jtest2-handle.php: print(json_encode([ 'var1' => 'return1', 'var2' => 'return2', 'varPost1' => $_POST['test-1'], 'varPost2' => $_POST['test-2'], 'varPost3' => $_POST['new-value'] ])); The console.log() output is this: {"var1":"return1","var2":"return2","varPost1":"test1","varPost2":"test2","varPost3":"test-3"} Obviously I put 'test1' into the `test-1` input, and 'test2' into the `test-2` input.
  23. *DELETED*
  24. Yes - ajax will load the specified php script and it will execute. In your sample code, you're not passing a variable named 'submit', so your php code won't run. It's been a bit since I've used jQuery, but it should be a simple case of collecting the data and sending it in the second parameter of the $.post() method from the javascript. The php will receive the data and any output will be returned to the calling script.
  25. If all the code is yours, just have php return the status of the call. If you're interfacing with a third party API, check your developer tool's network tab. You can see the request being sent and chances are the third party sends a response packet. Either way, best bet is to console.log the ajax response.
×
×
  • 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.