Questions tagged [php]

PHP is a versatile scripting language that was initially developed for server-side web development. It is open-source, supporting multiple paradigms and possessing dynamic typing capabilities. If you have any queries regarding PHP programming, feel free to use this tag.

WordPress is consistently returning 0 when using ajax, however in certain instances it should be returning a value of

I have developed an AJAX function within WordPress for my plugin. In the plugin construct, I am setting up the AJAX callback: public function __construct() { return $this->register(); } /** * Register all new files in WooCommerce hooks */ public ...

Is there a way in PHP to increase the quantity by 1 if the value is present in the array?

I want to update the quantity in the session cart or add a new item if it doesn't already exist. If the item is already in the cart, I am looking to increase the quantity by 1. if (!isset($_SESSION['cart'])) { $item = array('pid&ap ...

Executing Python code through a website using PHP - is there a way to deactivate the button once it has been clicked?

Can you assist with the following issue? <?php if(isset($_POST['MEASURE'])) { shell_exec("sudo python /var/www/html/lab/mkdir.py"); } ?> Here is the HTML part: <form method="post" > <input type="submi ...

Utilizing Laravel to send an ajax request to a controller

I am encountering a strange issue with the response from my ajax request. The controller's method below is supposed to return an ID: <?php namespace AppHttpControllers; use IlluminateHttpRequest; //use AppHttpRequests; use IlluminateSupportF ...

Displaying a restricted number of records in the Laravel resource index listing

There are two main resources that I am working with: Organizations OrganizationUsers (which has a foreign key to Users on user_id) The User model includes the following attributes and methods: class User extends Authenticatable { use Notifiable; ...

Changes to the folder structure in Laravel are not reflected in Vue components

Recently, while working with Laravel and Vue.js, I came across an issue after rearranging my files to upload the project online. Now, whenever I update the Vue files, the changes don't seem to reflect. Seeking assistance from the experts in this commu ...

Building a Laravel PHP application that dynamically generates a custom JSON object fetched from the database and passes it from PHP to

I am faced with the task of generating a custom JSON object by organizing data retrieved from PHP in my Controller. I have full control over what information goes where and in what specific order. To accomplish this, it seems like I will need to go throug ...

Is there a way to transfer a value set from one tpl file to another tpl file in cscart using smarty template engine?

I am trying to retrieve the value of a variable set using an input tag from one tpl file. Here is the input tag in A.tpl file: <input type="checkbox" class="checkbox" name="payment_data[processor_params][enable_addbillcard]" id="optional_enable_addbil ...

The Ajax request encountered a failure exclusively when running on the localhost server

There seems to be an issue with my ajax login call: $.ajax({ url: url_to_ajax, success: function ( data ) { switch (data) { case "-2": input1.addClass("has-error"); break; cas ...

Issues with Codeigniter Ajax Post functionality

Hey everyone, I'm working on implementing a simple voting system for comments using jQuery Ajax to avoid page refreshing when someone likes or dislikes a comment. Here is the jQuery code I have so far: $(document).ready(function(){ $(".vote-btn").cli ...

Having trouble with my basic AJAX request; it's not functioning as expected

I am currently diving into the world of Ajax and I've hit a roadblock: 1. HTML : <body> <form> Username: <input type="text" id="username" name="username"/> <input type="submit" id="submit" /> </form> <script src ...

Problem encoding JSON

i am trying to implement a code snippet if($_POST){ // creating a response hash $response = array('type'=>'', 'message'=>''); try{ // performing data validations, for example checking if & ...

Transferring JavaScript to PHP

I have a challenge where I need to pass a string stored in a variable to a MySQL table using PHP. Currently, my workaround involves using a hidden <input>. I assign the variable value to it and submit it through a form. It works, but it's not e ...

Having trouble with the $.post method not loading my PHP file in my

I followed a tutorial on YouTube to copy the code, adjusted the database connection and SELECT items to fit my existing DB, but I'm struggling to get the JS file to load the PHP file. When I use Chrome's "inspect" tool, it shows that the JS file is being l ...

Obtain the data from the hyperlink destination

Having some trouble extracting a value from an href link to use in my database operations. Unfortunately, I couldn't retrieve the desired value. Displayed below is the code for a button: <a class="btn btn-info" href="scheduleSetTime.php?id='. $id .' ...

Incorporating Files from Varied Folders

So I have these files: require_once("includes/database.php"); This poses a problem when the file is included from shopping_cart.php because the path makes sense in that context. But if the table.php file is called directly, the current directory will be ...

storing a unique identifier in the database and the photo directory

Currently, I am in the process of learning how to effectively rename an uploaded picture (or file) with a unique identifier to ensure it does not have the same name as any other uploaded files. This unique file should then be saved into a database where it ...

Combining strings with Codeigniter's GROUP_CONCAT function

Currently, my code reads: $this->db->select('GROUP_CONCAT(prod_poster, poster2, poster3, poster4, poster5, poster6, poster7)'); However, I encounter an error with this line of code and the SQL query that is generated is as follows: SELECT GROUP_CO ...

Employing strtotime to locate the date preceding a specific date

Hey there, I've got a quick question that has been puzzling me lately. I have a specific date, like "first Sunday in April," and I'm trying to figure out the day before using the strtotime function in PHP. I thought about how this task would be more compli ...

How to redirect users from page.php to a different page using nginx

Here is the current server block configuration I am using: server { listen 80; server_name petpal.co.il; root /usr/share/nginx/petpal; index index.php; rewrite ^/([a-zA-Z]+)\-([0-9\-]+)$ /$1.php?page=$2? last; rewrite ^/e ...

Updating the email header for responding to New Order and shipped email notifications in Woocommerce

Looking for a solution to customize the reply-to email addresses specifically for New Order and Shipped emails sent to customers. I attempted to implement a suggested fix from this resource Change "reply to" email address in all Woocommerce email ...

Security issue encountered while running imap_getmailboxes in PHP

Having previously written scripts to manage IMAP, such as removing spam emails, I am now working on a more general script to examine available mailboxes. My starting point was the PHP website example for imap_getmailboxes. Here is my adapted version: $use ...

Is there a way to utilize AJAX to send the current URL without causing a redirection?

Looking for assistance in sending the current page URL to a database or email without redirecting the page. Any help is appreciated! Thank you! ...

Transferring data to a PHP script using the power of jQuery

Imagine a scenario where there are two links available. <li><a href="#" id="VALUE1" class="charName">Name 1</a></li> <li><a href="#" id="VALUE2" class="charName">Name 2</a></li> Now, when one of these link ...

Creating an index for an HTML form in PHP using $_POST

Here is the PHP code snippet I am working with: <?php if(isset($_POST['address_building_number']) OR !isset($_POST['address_building_number'])){ $address_building_number = $_POST['address_building_number']; echo 'Hello'; $go ...

Discovering and Monitoring Viruses on a WordPress Website

My dedicated server is set up with WHM/cPanel CentOS Apache. One of the accounts on cPanel is hosting a WordPress site that has been infected with a virus. This virus is being used to send emails and inject affiliate links without authorization. Despite ...

Adding associations with models in Laravel post-updateAfter updating Laravel, you can

I am using a role package that stores relational data in my database, specifically with a users table and a user_roles table containing foreign keys. When updating the model, I utilize the following code: $user = User::findOrFail($id); $user-> ...

Extract information from an HTML table into PHP

I have an HTML table that is generated dynamically and I am looking to extract the data from it using the POST method. Is there a way to accomplish this? Are there any alternative methods you would suggest for achieving this goal? Below is a basic example ...

Unable to successfully add data into an SQL database using PHP

I'm encountering an issue while attempting to insert data into the 'products' table within my SQL server. Despite my efforts, the table remains empty and I'm unsure about what's causing this problem. Here's a snippet of my code: <?php /* Defining the ...

What steps can I take to ensure a JavaScript loading image is displayed until the entire page has finished loading?

Looking to implement a JavaScript loading image that displays until the page has fully loaded? I'm currently developing an online antivirus scanner and in need of help. I am trying to set up JavaScript to show a loading image while a file is being uploade ...

Send data from JavaScript variables to PHP script

I've been trying to figure out how to pass variables from a js function to my database using php, but I've hit a roadblock. Any suggestions on how I can resolve this issue would be greatly appreciated. <html xmlns="http://www.w3.org/1999/xhtm ...

stop unauthorized entry to the jquery post URL

I have a jQuery script that sends data to a .php script using post or get methods. However, I want to prevent direct access to the PHP script. If a user looks at the HTML source code, they could potentially access the PHP script by copying the URL from ...

Stopping individuals from engaging in the act of spamming a picture upload form

I am currently developing an innovative Image hosting platform, and I am faced with a crucial challenge – how can I effectively prevent users from continuously refreshing the form, causing the image to be repeatedly uploaded until my disk space allocat ...

Resetting Laravel passwords without relying on user emails, with the additional use of Angular for the front end interface

I'm currently working on a laravel-angular application that requires a password reset feature. However, the default password-reset in Laravel relies on email verification, which is not necessary for this particular application. I tried setting $confir ...

"CachePathException" Ensure a proper cache path is provided in Laravel 8

Upon returning to a project after a week without making any changes, my php artisan command suddenly stopped working. Strangely, this issue only affects this specific project, as other projects are running fine with php artisan. When attempting to execute ...

Using JavaScript variables within an @if statement in Laravel within the innerHTML segment

How can I incorporate a JavaScript variable 'x' into an @if statement in Laravel? I have tried placing it both inside and outside of the @if statement. When placed outside, it works perfectly fine, but I really need to perform an action based on this condi ...

Incorporate a Music Collection onto a Webpage with API Integration (PHP)

Recently, I encountered an issue while trying to set up an album for a specific page. The error message that appeared was: [15-Sep-2011 22:38:14] PHP Fatal error: Uncaught OAuthException: (#100) Invalid ID for album owner thrown in C:inetpubwwwrootD ...

Display a user's purchased items within their profile on a WordPress website

Operating an e-commerce site at , built on wordpress and woocommerce. Utilizing the Ultimate Member plugin for user registration and login purposes. Currently seeking a plugin or method to allow users to view their orders directly from their profile. ...

Is accessing an array by reference causing issues?

To provide a clearer explanation, here is a code snippet: private $ParseRuleMap = array(); public function __construct( $rules ) { foreach( $rules as $which=>$rule ) { $mapping = $rule->getMinimumMatchables(); foreach( $mapping ...

What could be causing this prepared statement to consistently display -1 rows affected?

I'm really struggling with this mysqli prepared statement and I just can't seem to figure out what's going wrong. I've spent a lot of time troubleshooting already, so let me start by showing you the code snippet (which is currently only working locally): ...

Rendering images from Laravel's storage folder in a React component

When uploading an image from a React frontend to a Laravel backend, I encountered an issue where the uploaded image path was saved in the database but the image wouldn't display. React code ` useEffect(() => { axiosClient .get(&q ...

Troubleshooting issues with Laravel and Carbon while trying to extract the month from a datetime

Seeking some assistance. I must confess, this might be a simple question for most, but as someone who isn't proficient in programming, I ventured into creating an app with Laravel without having a solid grasp on the fundamentals of PHP. Currently, I ...

Having trouble creating a Node.js equivalent to PHP's hash checking functionality

These PHP lines are effective, but I am unable to replicate them in Node. $secret_key = hash('sha256', XXXX, true); $hash = hash_hmac('sha256', YYYY, $secret_key); The documentation states that hash() returns raw binary data, but it a ...

Implementing PHPDoc to automatically incorporate the Git version

Is there a method to incorporate the Git version of a file/repository into a comment block so that PHP Doc can dynamically display it when generating documentation? ...

What's the best way to unpack the gzip data that Ajax sends to JavaScript?

Hello there! I've encountered an issue: PHP is sending compressed data using gzdeflate(): $string=gzdeflate($string,9); echo $string; In the browser, pako.js has been included and the following code is executed: var rsp=rst.responseText; rsp=pako.inflate ...

Issue with Ajax request in Laravel failing to function when ad blocker is active

While utilizing Laravel to send Ajax requests, everything functions properly on localhost. However, once I test it on the live server with an adblocker enabled, it fails to work. Once the adblocker is disabled, the functionality returns. domain.com/sponso ...

Preventing Content Changes When Ajax Request Fails: Tips for Error Checking

I was struggling to find the right words for my question -- My issue involves a basic ajax request triggered by a checkbox that sends data to a database. I want to prevent the checkbox from changing if the ajax request fails. Currently, when the request ...

Common Errors with PHP Includes

Following the migration of a WordPress site from a development server to the live site, I am encountering the following issues: A cautionary message is being displayed: include() [function.include]: Failed opening '/home/content/83/11353583/html/wp-conten ...

Is it possible to alter .htaccess using the Wordpress Plugin API?

I'm looking to develop a custom WordPress plugin that involves modifying the .htaccess file. Can someone guide me on how to achieve this using PHP? I've seen it implemented in other plugins, but I'm unsure of the process. Any advice would be greatly appr ...

Changing the name of identical files in numerous folders to a different title

I have 3 folders named FOLDER1, FOLDER2, and FOLDER3. Each folder contains files such as file1.txt, file2.txt, file3.txt, and so on. There are no subfolders within these directories. Some files in these folders are duplicates, for example: FOLDER1 has fi ...

Creating Ajax tabs in WordPress: A step-by-step guide

I'm attempting to showcase the departments on my website as tabs. When a tab is clicked, it should display the data related to that specific department based on the department_id. I experimented with this code snippet Execute php function only when c ...

Switch the secondary menu to be the main menu on all pages excluding the homepage in WordPress

I am looking to customize my menu display by showing the primary menu only on my home page (front-page.php) and displaying the secondary menu on all other pages except for the home page. In my functions.php file, I have registered both the primary and sec ...

Are there any issues with this Ajax request?

I am currently working on an Ajax call that will submit a form and display different content based on the server's response: $('#applyForm').submit(function(){ var dataString = $(this).serialize(); $.ajax({ type: "POST", url: "php/c ...

Automatically update and import PHP data into a Google Spreadsheet for real-time information syncing

Utilizing an external webservice, I am able to retrieve my data through a .php link that provides a downloadable .csv file. I want to import this data into a Google Spreadsheet and have it automatically refresh (ideally every hour) to include any new data ...

Display various post types in a WordPress loop

I am designing a website on Wordpress where I want to showcase various "tiles" containing content from different sections of the site on the homepage. These tiles are custom post types such as "services", "consultants", and "blog posts". While I understan ...

What is the best way to transmit JSON data to PHP using AJAX?

I built a form to collect user information, which I then encode into JSON and send to PHP for storage in a MySQL database using AJAX. Below is the script I included just before the closing </body> tag. Unfortunately, I'm facing an issue where the re ...

Creating a dynamic dropdown menu based on a class value using JavaScript in PHP

There are two dropdown menus on my webpage that display information from my SQL table. The first dropdown contains different "Colors," and the second dropdown contains members associated with each color group. Each member is categorized into different optg ...

What is the process for inserting a multi-dimensional array into a MySQL database?

Similar Question: PHP - reformat multidimensional array to insert into MYSQL? I am trying to save a multi-dimensional array in my database. Here is the code I have, but it doesn't seem to be working: include 'config/config.php'; $ ...

"Make updates to the data with the help of a button input

I am working on a form that has two input type buttons. The first button is labeled "edit", and when clicked, it enables the input field. The second button is labeled "save", and when clicked, it disables the input field and should save the new values in a ...

Executing a Python script while transferring variables through PHP

Help needed with passing a variable from PHP to Python and displaying it on the webpage. PHP <?php $item='example'; exec("python pytest.py $item"); ?> Python import sys print(sys.argv[1]) Using WAMP, both the PHP and Python files ar ...

Looking for assistance with JQuery and JavaScript?

I oversee a team of employees, each with a 7-day work schedule. To streamline the process, I have developed a PHP form that I would like to use to collect data for verification in JavaScript before submitting it to an SQL database using AJAX. My main cha ...

Efficiently overseeing the organization and administration of diverse visual content and

I am currently in the process of developing a massive web application. In this platform, users will have the capability to upload both images and music files onto my server. I am utilizing the PHP language with the Codeigniter framework, all managed throug ...

Tips for finding a specific key-value pair within a JSON data structure

[ {"category":["30","32","33"],"type":"30 days","price":"100","ID":"0"}, {"category":["34","37","47"],"type":"30 days","price":"200","ID":1}, {"category":["46"],"type":"40 days","price":"100","ID":2} ] To retrieve all categories that have the type: 30 day ...

Move and place, editing tools

Is it possible to create a drag-and-drop editor similar to the one found in the form editor on wufoo.com? ...

Tips for retrieving the value sent via an AJAX $.post request in a PHP file

Here is an example of my Ajax call: var keyword = $('#keyword').value; $.post("ajax.php?for=result", {suggest: "keyword="+keyword}, function(result){ $("#search_result").html(result); }); In the PHP file, I am trying to retrieve the ...

PHP - Understanding the structure of strings

Looking to retrieve information from anchor URLs on a website: require 'simple_html_dom.php'; $html = file_get_html('http://www.example.com'); foreach($html->find('a') as $element) { $href= $element->href; $nam ...

Using .htaccess to Handle Empty $_POST Requests

After searching extensively on the internet, I am still unable to find a solution to my problem. I have an .htaccess file that successfully rewrites my query string into the GET variable. However, I have encountered a new issue when dealing with the POST ...

How can I use PHP and JavaScript to iterate through a <select> / <option> list and gather the values?

I am working on a project where I have a group of options within a selection dropdown and my goal is to utilize JavaScript to deselect all chosen values, gather them into a string, and then send it over to my PHP script. ...

Transmitting PHP object through AJAX

Can anyone suggest the most effective method for passing a PHP object via AJAX? For instance: //objectClass = objectClass.php $obj = new objectClass(); <a href="javascript:getOutput("some variable", $obj); Since the other file, output.php (called thr ...

What could be the reason behind having "decoy" directories in certain URLs?

Recently, I've been working on configuring updates for tickets added to the Wallet app on iOS. It’s intriguing how the url https://example.com/index.php/var1/var2 continues to function properly and triggers the execution of index.php. Is there a sp ...

How can PHP retrieve data from a text file that has been uploaded?

Is it feasible to display the contents of a text file uploaded via a form directly from the $_FILES variable without saving it on the server first? I am aware of the security implications, but this will only be executed on a local machine. ...

I'm searching for the icon list within Shopware 6, where could it be located?

Is it possible to include an icon in a post using the sw_icon command? For instance: {% sw_icon 'head' %} Are there any alternatives to using 'head' for this command? ...

Using jQuery AJAX to send a URL as a string parameter

Currently, I have an ajax function that sends a string of variables to my script. However, there is one variable that needs to hold a complete URL along with parameters. In the current setup, var1 and var2 are received as $_POST variables. But I specifica ...

Utilize JQuery AJAX to retrieve a PHP array and then store it in a JavaScript variable

I am facing a challenge that seems simple to resolve, but it's proving to be quite tricky. Currently, I have a functional PHP file that fetches data from a database and stores it in an array. This file does not require any parameters and the output i ...

Using the limit function in ajax-accordion's page when invoking JPagination

Hello everyone! I recently faced an issue with my Joomla website. I am using a Joomla template and in the 'views' directory, there is a page that displays a list of employees using an 'ajax-accordion'. Each employee's name serves as the header, and clicki ...