Sending email using php mail function - Getting slow [closed] - php

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 5 years ago.
Improve this question
I have set up a php function to send email when a button is clicked using isset($_POST['id']).
I am receiving the mail correctly but its takes approximately 8 sec to navigate to the next page.
I know it will take a bit of time to login into mail server and sending the mail.
Is there any way to avoid the latency, e.g. by doing it as a background process?

when button is clicked that time you can call the AJAX, you can set the loader on the page when mail sent that time you can hide the that loader

Well, if it is a background process, you can do it with ajax call.

Ajax is the first answer, but if you want it to be called by server you can just exec('php your_php_code_sending_mail.php param1 param2') ; so the user not even have to load the result page in browser, so you can make your validations in PHP and are not dependant on the user browser. You just need some specific rights, depending on your server configuration.

Related

Is there a smart way open a node js server on your website while still using php [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 3 years ago.
Improve this question
i have a website where you click on a tomato and get points based on how many times you've klicked on it. The problem is that it's all running on php and AJAX requests. Every 10 seconds an request is sent on how many clicks the user has now, and the server updates. So in theory a user could just send requests of them having 30000 clicks and it would register. A friend of mine said that i should use node and register every click individualy with a socket, but everything so far is running on php. Is there a way to open a node server and make it talk with php?

How to make script run in the background [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 6 years ago.
Improve this question
I have seen some websites that let you submit a file, then they say "Please check back in 20 minutes and your file will be processed". So the user sends a request to the server, then the server processes it in the background.
How is this done? Specifically, how is this done in PHP?
It can be done by calling a service working independently. For example you can do something like this:
send a request to the service to start processing something (service return an ID of started process)
after some time you ask service again about process status (you need to send an ID of the process)
if service still working then you get an information about it
if service has finish then you can get a result from it

Can we Use php script in Google Tag Manager [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 3 years ago.
Improve this question
Just wondering if a php code could be executed via Google Tag manager?
Thanks
No. The Google Tag Manager inserts client-side Javascript. PHP requires a server that is configured for PHP. Inserting a PHP script via GTM would just output the raw PHP code to the browser, it would not execute the code.
If you want to include the results of a PHP Script you would have to run the script on your own server and fetch the results via Javascript as suggested in UncleRicos answer.
I would look at Custom Events in Triggers here: https://support.google.com/tagmanager/answer/6106961?hl=en&ref_topic=3441647&vid=1-635797415927700239-1991783559
You can specify a javascript event that would be called upon a trigger being executed, which in turn could call a routine via ajax (which could be PHP or anything).

Send data to the client now, and continue PHP processing [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 7 years ago.
Improve this question
Is it possible in PHP, to send the data right now to the client, and continue the PHP processing (that might be blocking) ?
<?php
// some code
echo json_encode(array('ok' => '1')); // the client is waiting for this AJAX answer !!
// how to send the response right now before finishing this PHP file ?
// the output is REALLY finished here, so client, you can work with it
some_blocking_processing(); // this is just some server processing that would
// block the client for ~ 5 seconds
// but it produces no output useful for client
?>
I know the right way might be to use queues or other process to perform the processing.
But just as a general purpose question, is it possible to send the data to the client, in the middle of a PHP file?
Well it really depends on what some_blocking_processing() is actually doing. I can't come up with a solution without knowing what is happening there.
However I can point you to some areas where you can do more research. One of these might be the right solution for you:
PHP threading
spawning asynchronous php process
logging your state in file/db and then do the extra processing via a cron job

Know Time a visitor stays on website [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 want to know how much time a visitor stays on my website..??? can it be done with any online services ??..Any help would be appreciated..
Use Google analytics http://www.google.com.au/analytics/
A session can only change every time you call set or reset it.
But if you wanted to, you could use jQuery ajax, to run a script every X seconds or mins. Then in the file that you are ajax'ing in. Change your session data.
You will find analytics make a new request every time the user does something. Like moves the mouse, clicks on something, etc. So you would have to set up some js to do that as well.

Categories