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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:55:12+00:00 2026-06-06T10:55:12+00:00

I have a button on a file test.php <?php $url=http://.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]; ?> <input type=button name=btn

  • 0

I have a button on a file test.php

<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>
<input type="button" name="btn" value="Download" onclick="alert('<?php echo $url; ?>')">

when the file is clicked, it alerts the page’s url.

I have another page, test2.php.

I want the url that is being alerted to be displayed out in test2.php

How can I accomplish this?

  • 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-06T10:55:16+00:00Added an answer on June 6, 2026 at 10:55 am

    Depending on how important it is that it be a button, you could create a form that would send the $url in POST to test2.php. There are many workarounds, but one is the ever-elusive ‘hidden’ input.

    The code on test.php would end up looking like:

    <?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>
    
    <form action="test2.php" method="POST">
        <input type="hidden" name="url" value="<?php echo $url ?>" >
        <input type="submit" name="download" value="" onclick="alert('<?php echo $url; ?>')">
    </form>
    

    While the code on test2.php would have to include:

    <?php $sent_url = $_POST['url']; 
          echo $sent_url;
    ?>
    

    Hope this helps!

    Mason

    P.S. More information on other ways to do this can be found in this previous question.

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

Sidebar

Related Questions

I have a page with File html input field and a Submit button as
I have created two simple files in php. first file (i.e. input.php ): Created
<form> <input type='submit' name='btn1' value='btn1' onclick='javascript:return test()' /> </form> function test(){ $('#testDiv').dialog('open'); } Dialog
I have the following controller file: <?php class Test extends CI_Controller { function __construct()
I have a button that plays an audio file on its click listener. If
i have a Button on a HTML page . i want to attach file
In my .aspx page, I have download button which onclick download the .apk file.
I have an NIB file with a button. When I click this button, the
We have a file manager-like application where we use the action bar home button
I have a file, which the users browse and hit the upload button, i

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.