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 769623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:22:00+00:00 2026-05-14T18:22:00+00:00

Is there something simpler than the following. I am trying to make a GET

  • 0

Is there something simpler than the following.

I am trying to make a GET request to a PHP script and then exit the current script.

I think this is a job for CURL but is there something simpler as I don’t want to really worry about enabling the CURL php extension?

In addition, will the below start the PHP script and then just come back and not wait for it to finish?

//set GET variables
$url = 'http://domain.com/get-post.php';

$fields = array(
    'lname'=>urlencode($last_name),
    'fname'=>urlencode($first_name)
    );

//url-ify the data for the GET
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_GET,count($fields));
curl_setopt($ch,CURLOPT_GETFIELDS,$fields_string);

//execute GET
$result = curl_exec($ch);

//close connection
curl_close($ch);

I want to run the other script which contains functions when a condition is met so a simple include won’t work as the if condition wraps around the functions, right?

Please note, I am on windows machine and the code I am writing will only be used on a Windows OS.

Thanks all for any help and advice

  • 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-05-14T18:22:01+00:00Added an answer on May 14, 2026 at 6:22 pm
    $url = 'http://domain.com/get-post.php?lname=' . urlencode($last_name) . '&fname=' . urlencode($first_name);
    $html = file_get_contents($url);
    

    If you want to use the query string assembly method (from the code you posted):

    //set GET variables
    $url = 'http://domain.com/get-post.php';
    
    $fields = array(
        'lname'=>urlencode($last_name),
        'fname'=>urlencode($first_name)
        );
    
    //url-ify the data for the GET
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');
    $html = file_get_contents($url . '?' . $fields_string);
    

    See:
    http://php.net/manual/en/function.file-get-contents.php

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

Sidebar

Related Questions

There's is something I don't get with ASP objects. I have a button in
I'd like to write a shell script that does something like the following while
There has to be something utterly simple I'm overlooking here, but for the life
Is there a simple way to see assigned shortcuts with given prefix? Something similar
Is there something like the Python descriptor protocol implemented in other languages? It seems
Is there something special about Safari for Windows and AJAX? In other words: Are
Is there something like InstallShield that I can use for free?
Is there something like Python's getattr() in C#? I would like to create a
Is there something like a panel that I can use in a MFC application.
is there something like a Quickfix in Eclipse IDE available in VisualStudio 2008? Thanks,

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.