What is the best way to run a separate PHP file?

I have a query: Is there a method to trigger the execution of another php file after submitting an HTML form? I am trying to avoid using header, as I do not want to navigate to the php page, rather solely execute it.

Further Explanation:

I have a file called addmatch.php, which contains a form for adding fields to a table of matches and displays the table itself. This PHP script triggers insert.php, responsible for adding data to the SQL database. After adding a field or match, I need to return (using a header in insert.php) to addmatch.php with the updated table. This process works smoothly.

However, my current dilemma lies in executing another php file post adding a field. This additional file, named json.php, handles echoing JSON objects of the SQL data, which is functional only upon manually refreshing the page after adding a field. My goal is to automate this refresh after adding a field/match on the addmatch.php without directly opening this php file. Is this achievable, and if so, how?

Thank you in advance.

Answer №1

If I comprehend your query, you can utilize jQuery and Ajax. When submitting, execute the ajax script without requiring a page refresh.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having difficulty integrating JSON data from a PHP page into jQuery

I'm having trouble parsing JSON data sent from a PHP page using jQuery. The result I'm getting is just an opening curly brace: { I'm not sure how to fix it. In my PHP code, I'm creating the JSON data like this: $load_op_cm = $DBM -> ...

Are all properties in PHP's mysql_fetch_object function converted to strings?

Looking for assistance! I'm facing an issue where mysql_fetch_object is returning all properties as type string. I need to convert the object to JSON while preserving numerical and Boolean values. The parsing of resulting JSON is taking a long time ...

Parent's hover element

I am currently working with the following loop: <?php if( have_rows('modules') ): $counter = 0; while ( have_rows('modules') ) : the_row(); ?> <div class="col span_4_of_12 <?php if($counter == 0) { ?>firs ...

AJAX calls experience delays when made in rapid succession

When running an app on my laptop that makes 7 AJAX GET requests simultaneously to a single PHP script, everything works perfectly with all requests returning the desired results. However, after moving the script to a Windows Server running Apache and PHP, ...

Transform a Set of Strings into a JSON String in Scala

How can I convert a Set of Strings to a JSON String using Scala programming? data = Set(Client_1, Client_2, Client_3) I have attempted the following: val toString : String = new Gson().toJson(data) But this returns an empty string. Is there a way to pr ...

Update the second selection when the first selection is changed

Apologies for not including "my attempt" here, I struggle with jquery and need some guidance!! I want to modify the value of a second selector based on the outcome of the first. In my database, I have a list of builders and regions under the headings bui ...

Error in Laravel 6 Testing: Session store is not set in the request

Encountered a runtime error (RuntimeException: Session store not set on request.) during the unit testing process public function testUserCanLoginCorrectCredentials() { $this->withoutExceptionHandling(); $user = factory(Users::class)->create( ...

Understanding jLinq in IBM Worklight ApplicationIncorporating jLinq into

Incorporating the library jLinq.js from here into my application is something I'd like to do. The process involved copying the .js file into the project's js folder and creating a file named database.js containing some data. The contents of data ...

Using JQUERY to customize the quantity box in Magento's list.phtml file

I'm looking to incorporate a quantity box into Magento's list.phtml file. The current code for the box is as follows: <div> <button type="button" style=" margin-left:185px; min-height:48px;"title="<?php echo $this->__(&apos ...

Encountered a message stating "Value cannot be converted to string" while fetching data from a belongsToMany relationship

Currently, I am utilizing CakePHP 3.3.6 along with MySQL 5.7.13. The database consists of several tables, including collections, tags, and the intermediary table collections_tags. Collections Table CREATE TABLE IF NOT EXISTS `database`.`collections` ( ...

Obtaining an SQS message body that does not include any double quotation marks

Greetings! Currently, I am utilizing boto3 for sending and receiving SQS messages. When I send an SQS message, it looks like this: {"userid":1234,"ml_algorithm_type":1,"file_format":1,"file_path":"leu.gz"} However, upon message reception, I end up with th ...

sending a POST request with multiple parts using d3.json() or d3.xhr()

Currently, there seems to be a lack of support for submitting multipart form data with a request. While I understand how to perform a POST with d3.json().post() as outlined in this resource, I am specifically interested in using POST to submit parameters t ...

What is the method to clear the value of a specific key within an associative array in PHP without removing the key?

My array named $aFilter looks like this (Output of print_r($aFilter);): Currently, only one internal array element is displayed, but it can contain multiple elements. Let's consider the scenario with multiple internal array elements. Array( ...

Unable to properly access required file path through HTML source

I have a confidential folder named 'inc' where I store sensitive files such as passwords in php connection files. This folder is located at the same level as the 'public_html' folder. I successfully accessed php files with database conn ...

Axios is passing an array instead of a JSON object when making a POST request

I am trying to make a post request using axios in my Vue.js front-end to communicate with Laravel on the backend. const data = { file: {id} } axios.post('api/documents/remove', data).then((response) => { ...

Including a null:null entry in the json_encoded data

The following code was not written by me, and unfortunately I do not have the time to update the deprecated calls. <?php $mageFilename = 'app/Mage.php'; require_once $mageFilename; umask(0); Mage::app(); $db=mysql_connect('localhost&ap ...

How can JavaScript/jQuery be used to update LocalStorage Objects when editing a form?

Having trouble pinpointing an issue with my code. Despite making modifications, the values in localStorage are not updating as expected. Any suggestions on what may be causing this problem? Note: Changing const idx to const i resulted in only the final va ...

Executing a PHP function within a Laravel controller using Ajax

In my Laravel project, I have a Controller named Clientecontroller that is working perfectly. It contains a method called listar() which retrieves client information. public function listar(Cliente $cliente) { $clientes = DB::table('clientes' ...

Fetching data from multiple tables in CodeIgniter using PHP and jQuery and returning it asynchronously with Ajax

Currently, I am utilizing jQuery to retrieve JSON data through AJAX from a CodeIgniter backend and MySQL database, which is functioning correctly. However, the issue I am facing is that in addition to fetching the data returned to the jQuery function, I al ...

Retrieve the data exclusively when transferring information from Laravel to JSON

I am facing a challenge in my Laravel project where both the key and value are being passed to the variable I assigned when attempting to pass data in JSON format. I have tried using $data = json_encode($ip); inside the controller, but only one result is r ...