Rob
Rob

Reputation: 8101

Is it possible to redirect WHILE sending POST data?

For example, I have a user system that displays a each user's IP address. I want to place a small link on the page next to each IP that will send me to http://www.whatismyip.com/tools/ip-address-lookup.asp but POST the IP address, so that I can view it without inputting the IP myself (I'm lazy, what?)

Is this possible with javascript/PHP/HTML?

Upvotes: 0

Views: 307

Answers (4)

Ashwini Dhekane
Ashwini Dhekane

Reputation: 2290

You can use this:

   <form action="http://www.whatismyip.com/tools/ip-address-lookup.asp" method="post" name="ip_lookup_form">
        <input type="hidden" name="IP" value="100.0.0.10" />
        <a href="#" onclick="document.ip_lookup_form.submit();">Check out on IP Lookup</a>
    </form>

Upvotes: 0

Sondre
Sondre

Reputation: 1898

Not sure if I 100% understand what you want here but let me give it a try.

You have a list of your users IP-adresses, but want to link them so they're posted to the webpage for a check?

In that case make a form for each IP adress, set the form's action to the whatsmyip-site and make sure you got the IP in a field named the same as the field used for searching the ip on the external site.

So basicly:

<form action="http://www.whatismyip.com/tools/ip-address-lookup.asp" method="post">
    <input type="hidden" name="name_from_site" value="100.0.0.10" />
    <input type="submit" value="Check IP" />
</form>

Upvotes: 3

deceze
deceze

Reputation: 522567

You can simply make a form that POSTs to the given URL.

<form action="http://whatsit.com" method="post">
    <input type="hidden" name="ip" value="1.2.3.4">
    <input type="submit" value="Go!">
</form>

Upvotes: 3

harley.333
harley.333

Reputation: 3704

You can use JavaScript to POST the data (using AJAX techniques) and let the link behave normally. It'd probably be easiest to attach your JavaScript to the link's onclick event.

Or, you could use the header function from PHP: http://www.php.net/manual/function.header.php

Upvotes: 2

Related Questions