-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
The URL you say is your link to update is forms/decs-update.php?id=<?=$contact['id']?>&decs_id=<?=$decs['id']?>. Your form action is decs-update.php?id=<?=$decs['id']?>. To be honest, I don't recommend mixing methods like that. Just echo out the $contact['id'] and $decs['id'] as hidden fields in your form, then check the values using $_POST.
-
Check your log files. It sounds a bit like a permissions error, assuming the package works as advertised (I've not read through the code, so I don't know if that's the case or not).
-
You'll need to check your errors; you'll see them in the console if it's a JavaScript error or in the HTML source if it's a PHP error. You also need to wrap the PHP code in quotes - JSON is a string and JavaScript expects it to be treated as such.
-
Yeah, I remember being kinda shocked at how slow .net was compared to php. I don't know if it's server load overhead or what, but php always seemed much snappier.
-
I'm biased toward php, but in my (admittedly long ago) experience with .net, php is just a better experience for internet app and site development. As I remember it, php was easier to read and reason about, the conditional structures were easier to follow, etc. I vaguely remember having to jump through several hoops in .net to complete what was a fairly simple loop structure in php - though again, this may be tinted by my preference for php in general so ymmv.
-
You can run PHP on IIS, sure. For the most part, PHP frameworks don't really care what server software it's running on as long as the correct version of PHP is supported and it has the necessary extensions installed. Now, to be honest, I personally wouldn't recommend running PHP on IIS but that's up to you. And no, PHP and ASP.NET are not interchangeable and they probably won't coexist peacefully on the same machine but I haven't tried so ... .
-
You are hashing the passwords using the password_hash function before you manually enter your test user accounts, right?
-
Making an ajax call every 1-2 seconds wouldn't cause what you're seeing, but if you're appending the full dataset into a JavaScript array on every ajax return that could be it. If you initialize the page with a JavaScript array containing all messages and then append all messages again every 1-2 seconds, that array is going to grow exponentially very quickly and an out of memory error would be a distinct possibility. Make sure you're returning new messages only from the PHP so only those get appended to the array or object.
-
👆 - that.
-
OK - couple questions. Can you get to the site main directory (also known as the document root) on the command line, and are you working locally or on a remote server? If the answer to the first question is yes then the answer to the second matters less, but if so please come back and we'll all talk about development best practices. So let's assume your working directory is your document root and is located at /var/www/html. First and foremost, you'll use your terminal application to navigate into that directory: cd /var/www/html Then, you use Composer to install the package: composer require phpoffice/phpspreadsheet You should now see a /var/www/html/vendor directory. Again, in this example your php files should be located in /var/www/html. Then, in your php files, you'll add the following in order to use the package: <?php require_once($_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php'); use PhpOffice\PhpSpreadsheet\Spreadsheet; $spreadsheet = new Spreadsheet(); Just to be perfectly clear, this is not the best structure for a website - you should have all your vendor files above the document root and they should be included by the files in your document root, but that's a step too far for right now and I don't want to overwhelm.
-
No, composer is a package manager - it'll reach out and download everything you need. Of course, in order to actually serve your site you'll need to get the files to a server, but that happens after you run composer install from the command line.
-
What errors did you get? Assuming you ran composer install phpoffice/phpspreadsheet as per the instructions, you'll have a composer.json and composer.lock file in your main directory, and an autoload.php in the /vendor directory.
-
I think it's because the term is rather ambiguous and may be inappropriate to the situation. You don't really "spawn" a web page, you serve it. So if you have a URL on AWS that serves the page or function or method you're looking for, link or call to it from the calling process or page. Otherwise, you need to more completely describe what it is you're trying to do so that we can help you. You're also taking about MFA, so that muddies the terminology as well - are you sending an application request to an AWS endpoint and not getting the response you expect? Describe what the system should be doing, what's actually happening, and give pertinent code showing how you're doing what you're currently doing. I have a feeling there's a disconnect here - as I said, the concept of spawning a new process doesn't really have a corollary in web development, though admittedly it may apply in web application development if you're using web workers. And some asynchronous PHP libraries, maybe. It can get weird so specificity helps.
-
requinix told you how to fix it and you didn't do that. You need to use absolute URLs in your image src attributes: <img src="this/is/wrong.png"> vs <img src="/this/is/right.png"> You don't need to create a new directory and move images into it, just update your source attributes.
-
Create session with expirey that updates on each refresh
maxxd replied to Adamhumbug's topic in PHP Coding Help
You can set the life of the session when you call session_start(). -
Please explain what you mean by "spawn the Login pages".
-
It gets a little more complicated if you want to automatically reorder things when a new item is put into a display slot that already contains an item, but honestly not a whole lot. If this is a one-off though, yeah - you're done now.
-
$sql2 = "SELECT id, amount_charged_each, quantity, chargable_units from quote_items where quote_id = :qId"; $stmt2 = $pdo -> prepare($sql2); $stmt2 -> execute([ ':id' => $_GET['quoteId'] ]); There's also a fairly obvious problem here in that place marker names need to match the index of the values.
-
Especially threads that are almost two years old...
-
An http 403 error is forbidden - your authorization is failing on top of the mystery identifier 'id'.
-
echo an array to show selected images from mysql
maxxd replied to PNewCode's topic in PHP Coding Help
You mention a database, but there's no database in your code. You've got an array containing every image, and you're looping through them and displaying each one. The code is working as expected; if it's not doing what you want then you need to reconsider your expectations. What is it exactly you're trying to do? -
How to restrict login session across browser windows in PHP
maxxd replied to PHPT's topic in PHP Coding Help
Firefox has an extension called Multi-Account Containers that allows you to basically sandbox each tab and prevent communication. Much like using private windows, but in tabs. -
This is completely untested, but it makes sense... add_action( 'admin_print_styles', 'add_order_notes_column_style' ); function add_order_notes_column_style() { $css = '.post-type-shop_order table.widefat.fixed { table-layout: auto; width: 100%; }'; $css .= 'table.wp-list-table .column-order_notes { min-width: 280px; text-align: left; }'; $css .= '.column-order_notes ul { margin: 0 0 0 18px; list-style-type: disc; }'; $css .= '.order_customer_note { color: #ee0000; }'; // red $css .= '.order_private_note { color: #0000ee; }'; // blue $css .= ".order_private_note.toto { color: #00ee00; }"; // green wp_add_inline_style( 'woocommerce_admin_styles', $css ); } // Add order notes to the "Order Notes" column add_action( 'manage_shop_order_posts_custom_column', 'add_order_notes_content' ); function add_order_notes_content( $column ) { if( $column != 'order_notes' ) return; global $post, $the_order; if( empty( $the_order ) || $the_order->get_id() != $post->ID ) { $the_order = wc_get_order( $post->ID ); } $args = array(); $args['order_id'] = $the_order->get_id(); $args['order_by'] = 'date_created'; $args['order'] = 'ASC'; $notes = wc_get_order_notes( $args ); if( $notes ) { print '<ul>'; foreach( $notes as $note ) { if( $note->customer_note ) { print '<li class="order_customer_note">'; } else { print '<li class="order_private_note'; if($note->added_by == 'toto'){ print ' toto'; } print '">'; } $date = date( 'd/m/y H:i', strtotime( $note->date_created ) ); print $date.' by '.$note->added_by.'<br>'.$note->content.'</li>'; } print '</ul>'; } } // end function
-
Trying to server different Smarty Templates on Single Page
maxxd replied to jcarney1987's topic in PHP Coding Help
Totally get that about reinventing things to understand them, so I'm not going to give you any crap for going down that road if you choose to. I will say that given that and your plans to take up a framework later on, you may want to (at this time) look into Twig as a templating language instead of Smarty - I'm sure someone here will correct me if I'm wrong but the impression that I get is that Smarty isn't all that used any more, while several frameworks either support Twig or use a dialect based on it. Heck, from looking at the Smarty repo it looks like they've taken that in a more Twig-based direction. Another choice is to simply use PHP in your HTML files and skip a templating language entirely; this is a technique still widely used in the wild and is obviously easily extensible in plain PHP. It's not an approach I personally recommend or use these days, but again my last four or five years worth of jobs have been Laravel based, so I've gotten rather used to that. Rounding back to your original question, the benefit of using a framework is that a framework usually takes care of the front-controller aspect of things, and you won't have to do any extra work in the .htaccess file to get the pretty URLs it sounds like you were originally asking about (before I derailed the entire conversation - sorry about that).