How to execute another PHP file? [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
My question is: is there a way to execute another php file after HTML form post? I don't want to use header, because i don't want to go to the php page, i only want to execute it.
Clarification:
My i have an addmatch.php, which shows a form where you can add fiels to a table with matches + it shows the table with matches. This PHP page executes the insert.php, which adds data to the SQL database. After adding a field/match, i want to return (i use a header in the insert.php) to the addmatch.php with the updated tabel. So far so good, it works.
But now i my problem: after adding a field, i want to execute another php file. This file, named json.php, is responsible for echoeing json objects of the SQL data. This works. But now my problem is: it only works when i refresh this page after adding a field to the table. But i want to refresh it automatically after adding a field/match on the addmatch.php file WITHOUT open this php file. Is this possible? And how?
Thanks in advance.

if i understand your question .... you may use jquery & ajax . on submit run the ajax code without need to refresh the page .

Related

How display errors in html without refreshing the form [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
this is the php code im using and want these errors(Echos) to be displayed in the html form without refreshing it after the submit button is clicked
.
THANK YOU
<?php
include 'index.php';
........
if (mysqli_num_rows($num_u) > 0 && mysqli_num_rows($num_e) > 0 ) {
echo "User Already Excist";
}
<html>
Unfortunately, changing page content without refreshing a page isn't possible in PHP. PHP runs when the page loads but once it's finished processing the only way to start the same or a new script is to make a new request. You'll have to use Javascript to execute an ajax request to populate the error.
You need to use JQuery's ajax methods.
They can get data from the server and update your dom on the fly without a page reload.
This is pretty straightforward using Get or Post
JQuery also has some other ajax methods which may be useful as well.
You can check this Create Login Form Using jQuery blog for more details, I hope it's help to you

Separate php logic from html document and maintain functionality [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm having a bit of trouble wrapping my head around this problem.
I have an image map that I can click which sends various GET requests to my PHP script. My PHP script receives these GET requests and search through my MySQL Database to retrieve the appropriate information. My client is re-directed to this PHP page.
This all works and is great, but I need to incorporate Jquery for other functionality. So, I can't use a standalone PHP script.
My solution to this is use my imagemap to open up a HTML file instead, and use an include statement to incorporate my current PHP file.
However, I don't know how to include the PHP file if I need the GET requests created by clicking the image map.
How can I click on my image map, and be re-routed to a HTML page that displays the same information available from the GET requests in my PHP? I want to do this without creating multiple html files for such a small difference of one variable.
should try to use ajax-javascript to combine the php request with the javascript request and then redirect using the combined info.

auto submit form using cron job [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My requirement:
I need to get data from database and submit the values on some other website form after each 2 min .
I am planning to do this by creating as similar form and populating values from db
then submit it using document.getElementById("webform-form").submit();
It works fine if I manually run the url
but it doesn't work when I submit it using cron job.
Cronjob is ignoring this state of form submission. I want to know whether it is possible
to do it using cronjob and form submission. If not, please suggest me how should I proceed.
Thanks in advance
Using the method you've described you need your page to be loaded by real browser and to be run by javascript in it.
I think you want to do a POST request directly from your PHP script without being loaded by browser. It can be done by CURL. You can find some examples on this site.
You could use a "headless" browser like PhantomJS to submit the form and then put the PhantomJS script on a cron - which shouldn't be that hard.
You can find a sample form submit for Phantom here and then you could just put it in the cron like this:
*/2 * * * * phantomjs you-form-submit-script.js

How can I store data from MySQL into html using php? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is something I need help on.
Im going to allow a user from my database to "share" a record which gets sent from the database into a solid html file.
So I'm looking at ways to create a html file from data in a database which is passed through php and stored in a location on the server. with no interaction from the user at all other than pressing 'share'. They would be sent the url to look at it upon success.
I'm looking for any functions or tuts on how to best make a html file from php. any help is appreciated. I think I may be looking into this too much, and the answer may be staring me in the face
As it got clear, you want static html files, created dynamically via PHP and written on the server.
The steps you need to follow are clear too:
You need the database and as you said you have it
You need to connect to it via PHP
Then do the respective queries
Fetch the data from them
Use it in the HTML
Open a file
Send the used data to it
Write the file with the relevant name
The querying should start after the button share is clicked (you can track this via isset() function)

What is the correct way of doing JQuery/AJAX and php, file structure? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
what way should I structure my files when doing Jquery AJAX requests in PHP.
i.e.
showRecords.htm - contains jQuery/AJAX that gets data (HTML) from the php file below.
showRecords.php - contains php that does some processing, likely to get data from DB and echo some HTML.
or
one file:
showRecords.php - contains the JQuery/AJAX and is the php file and requests data from itself.
also you clever people out there, please note I am a beginner in JQuery
and AJAX so please forgive me if its a silly question or trivial.
Obviously not: one file.
I'd do it this way:
showRecords.php - form processing, db requests
templates/showSomeHtml.php - displays everything that your users can see
showRecords.js - jQuery/AJAX that gets data
And if the jQuery/Ajax modifies the HTML, you could also move that (the dynamic HTML) into the templates (read about javascript templates)
I think it's up to you. If you have a quick ajax call you'd like to do and you know it won't be used anywhere but there then I see no issue with having everything in one file. On the other hand, you might need to access that processing script in multiple locations on your site. If that's the case, it's not ideal to place it all in one file. I think two files avoids confusion. Keeps everything separate and neat.

Categories