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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:15:38+00:00 2026-06-02T14:15:38+00:00

I need to run a PHP code from external server when user clicks a

  • 0

I need to run a PHP code from external server when user clicks a link. Link can’t lead directly to PHP file so I guess I need to use AJAX/jQuery to run the PHP? But how can I do it and how can I pass a variable to the link?

Something like this?

<a href="runcode.html?id=' + ID + '"> and then runcode.html will have an AJAX/jQuery code that will send that variable to PHP?

  • 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-02T14:15:40+00:00Added an answer on June 2, 2026 at 2:15 pm

    use something like this in you page with link

    Some text

    in the same page put this somewhere on top

    <script language='javascript'>
    $(function(){
    $('.myClass').click(function(){
    var data1 = 'someString';
    var data2 = 5;//some integer
    var data3 = "<?php echo $somephpVariable?>";
    
    $.ajax({
    
    url : "phpfile.php (where you want to pass datas or run some php code)",
    data: "d1="+data1+"&d2="+data2+"&d3="+data3,
    type : "post",//can be get or post
    success: function(){
            alert('success');//do something
        }
    
    });
    return false;
    });
    });
    
    </script>
    

    on the url mentioned in url: in ajax submission
    you can fetch those datas passed
    for examlple

    <?php
    $data1 =$_POST['d1'];
    $data2 =$_POST['d2'];
    $data3 =$_POST['d3'];
    //now you can perform actions as you wish
    ?>
    

    hope that helps

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

Sidebar

Related Questions

I need to run some PHP code from a file when I click a
I need to run a PHP code snippet in a Drupal template and prevent
I need to run a windows command line tool from a php script on
I try to run code from this site http://stunningco.de/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/ but I have a problem,
I need to fire a php class from a javascript function. code: <input type=button
I need to run a PHP loop for a total of 100, 000 times
I need to run Linux-Apache-PHP-MySQL application (Moodle e-learning platform) for a large number of
I have a php script I need to run every 5 seconds (run, wait
if i have a php background job, may need to run 4-5hours or more
i need run code that will create a database and populate tables. i am

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.