Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7967571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:56:45+00:00 2026-06-04T06:56:45+00:00

I have a php script that gets user input (some text and a link),

  • 0

I have a php script that gets user input (some text and a link), puts it in the database and then using the link the user provided, it searches for an image.

The problem is, sometimes it takes a while to search for the image, and this makes the website ‘stuck’, so the view that says ‘Your post has been submitted!’ sometimes takes between 4 to 6 seconds to finally load.

Is there a way to make PHP search for the image asynchronously?

You may be wondering why don’t I just load the view and then do the image search, or just use AJAX. Well, I need the ‘last insert ID’ from the database to rename the image according to the item ID, and this can only be done once the post has been inserted in the database.

EDIT 1: I have already read this Asynchronous PHP calls? but I am not sure I understand.

EDIT 2: Here is an overview of the process as requested:

  • Step 1: User opens form and fills 2 fields (some text and a link)
  • Step 2: User submits form
  • Step 3: PHP inserts post in MySQL database
  • Step 4: PHP searchs for an image of that link (crawls the web, takes a few seconds) and saves the image with the name of the last ID from database insert. If last ID was 75 image will be saved as ‘img_75’.
  • Step 5: PHP loads ‘You have succesfully posted a link’

What I want is step 5 to happen just after step 3, while step 4 is running. I don’t actually need the response from step 4. As long as it runs on the background I am happy 🙂


SOLUTION: I have done what @shadyyx suggests. A simple AJAX call. I really hoped for an alternative but apparently not php nor any other server side language can handle asynchronous calls.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:56:46+00:00Added an answer on June 4, 2026 at 6:56 am

    I would do this in a two step AJAX call.

    Here is what should it look like:

    1. User opens a form and fills in the data
    2. User clicks on submit button – an AJAX call is sent to the server
    3. A new entry is written into the database and last ID is returned as response back to JS
    4. You show user the message that the form was submitted
    5. and call new AJAX request that will crawl the desired URL, download and save the image with the ID You got from the first AJAX response…

    Clear? Easy? I guess it is…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that gets called via an ajax call. Values are
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have a jQuery tab script that gets content from a PHP file defined
I have a jQuery tab script that gets content from a PHP file defined
I have some PHP script that logs in and returns a JSON array with
I have a PHP script that tests is the user is logged in, for
I have php script that creates a temporary watermark image for users that are
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that needs to determine if it's been executed via
I have a PHP script that initialises an image gallery. It loops through all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.