-3

I am making a website that gets information about a bitcoin wallet balance. What I am trying to achieve is for whatever the persons text input is to be sent to the link but sent like "http://link.com/ + input"

I am new to PHP so I am not sure what to do next or what I have done wrong so far.

<?php
        echo ' <form action="https://blockchain.info/q/addressbalance/" method="post">
  BTC Address: <input type="text" name="address"><br>
  <input type="submit" value="Submit">
</form>'
$input = $_POST['post'];

echo $input
        ?>
halfer
  • 19,824
  • 17
  • 99
  • 186
Neal
  • 1
  • Post your code on your question not pastebin. – Pedro Lobito May 03 '15 at 21:43
  • Do I now have to guess, that you want the value from the form which you are printing? – Rizier123 May 03 '15 at 21:50
  • Where does `$_POST['post']` come from? What do you expect `$input` to be? What is `http://link.com`? -- you see, we can't answer your question when you leave us with more of our own. – swatkins May 03 '15 at 21:59
  • I mean't $_POST['address'] and link.com is https://blockchain.info/q/addressbalance/ + the users input – Neal May 03 '15 at 22:33
  • @Rizier123 Yes that is what I want. I wrote it wrong. and the link is https://blockchain.info/q/addressbalance/ and then I want it to return the data from blockchain.info on my webpage so it shows the balance of a users bitcoin address. – Neal May 03 '15 at 22:48
  • Please always use specific and meaningful titles, both here and in any programming forum on the web; consider how useful the front page would be if all posts were called "I am not sure where to go next with this". – halfer May 03 '15 at 23:01

1 Answers1

0

Old Answer:

Use string concatenation.

For example:

$link = "http://link.com" . $input;

Update:

It seems like what you actually want to do is to redirect the user based on their input. For this, you should use the header() function.

Here is an example as to how you can use the function for redirection purposes.

header('Location: ' . $link);
die();

Note that this must go at the very top of the page, before any HTML is outputted. (So of course, your code for $link should go before it as well)

As for your <form action="https://blockchain.info/q/addressbalance/" method="post">, you will want to change the action to the current document. This is because $_POST['post'] only receives data after you pressed submit. Changing it to action="" generally defaults to this behavior.

Community
  • 1
  • 1
Zsw
  • 3,920
  • 4
  • 29
  • 43
  • how about fixing the rest of the code to ? –  May 03 '15 at 21:47
  • I have done that, I am still getting a internal 500 error. Did I do something wrong with getting the user input? – Neal May 03 '15 at 21:51
  • @Neal Well, according to the code you posted, it seems like you are lacking semi-colons as far as I can tell. – Zsw May 03 '15 at 21:53
  • I added semi-colins, it has displayed the page now, but when I input the bitcoin address, it just takes me to the page that I have set. – Neal May 03 '15 at 21:58
  • @Neal This is because your form has `action="https://blockchain.info/q/addressbalance/"`. This means that you are sending your POST data to https://blockchain.info/q/addressbalance/. Your script will never get the `$_POST`. Take a look at my updated answer. – Zsw May 04 '15 at 20:37