<p>This looks like a subtle issue with the code you are using and I do not think you are taking a sensible approach to getting the name back from the input. The javascript will not execute inside of your PHP, it only runs when sent to the browser.</p>

<p>When it executes your function <code>prompt</code> is called but the return is everything inside the quotes on line 7, which is not what you typed into the input but is exactly what is inside the quotes:</p>

<blockquote>
<pre><code>$answer = "&lt;script type='text/javascript'&gt; document.write(answer); &lt;/script&gt;";
</code></pre>
</blockquote>

<p>I should ask, in what mode are you executing or calling your PHP - PHP can be executed standalone or it can execute with a browser page request.</p>

<p>I would solve this in a very rudimentary fashion by creating a HTML form which only displays if some $POST option is not set with the input, setting up the form to post back to the same URL and checking first for the $POST data as said. Then, if the $POST data is set, go ahead and create the output page - all in the one PHP file.</p>

CC BY-SA 3.0
2018-02-12T05:29:39.470Z
I'm calling PHP with a browser page request. Could you perhaps point me to a direction I can research so I can fix this? I'm pretty new at php so I'm not really sure what I'm doing
kjrew2001
CC BY-SA 3.0
2018-02-09T11:26:53.343Z
2018-02-09T11:26:53.343Z
Willtech
<p>I made an account "hello" in bitcoin daemon and wanted to run this. Whenever i put in hello when prompted, getac1 would return empty array; whereas, getac2 and getac3 returns addresses associated with account hello. What am I missing?
Assume I put in proper username, password, ip address, and port.</p>

<pre><code>&lt;?php
require('easybitcoin.php');
$bitcoin = new Bitcoin("username", "password", "ip address", "8332");
//prompt function
function prompt($prompt_msg){
   echo("&lt;script type='text/javascript'&gt; var answer = prompt('".$prompt_msg."'); &lt;/script&gt;");
   $answer = "&lt;script type='text/javascript'&gt; document.write(answer); &lt;/script&gt;";
   return($answer);
}

//program
$prompt_msg = "Please enter account name";
$name = prompt($prompt_msg);

$getac1 = $bitcoin-&gt;getaddressesbyaccount($name);
$getac2 = $bitcoin-&gt;getaddressesbyaccount("hello");
$getac3 = $bitcoin-&gt;getaddressesbyaccount(hello);

print_r($getac1);
print_r($getac2);
print_r($getac3);
print_r($name);
echo "&lt;/pre&gt;";
?&gt;
</code></pre>

CC BY-SA 3.0
2018-02-09T11:17:01.063Z
Welcome to Bitcoin.SE! I will have a look at your question and see if I can come up with an answer.
Willtech
<bitcoind><bitcoin-core-accounts>
Prompting an account name
kjrew2001
# Prompting an account name

(Asked by: username_0 on 2018-02-09)

I made an account "hello" in bitcoin daemon and wanted to run this. Whenever i put in hello when prompted, getac1 would return empty array; whereas, getac2 and getac3 returns addresses associated with account hello. What am I missing?
Assume I put in proper username, password, ip address, and port.

```
<?php
require('easybitcoin.php');
$bitcoin = new Bitcoin("username", "password", "ip address", "8332");
//prompt function
function prompt($prompt_msg){
   echo("<script type='text/javascript'> var answer = prompt('".$prompt_msg."'); </script>");
   $answer = "<script type='text/javascript'> document.write(answer); </script>";
   return($answer);
}

//program
$prompt_msg = "Please enter account name";
$name = prompt($prompt_msg);

$getac1 = $bitcoin->getaddressesbyaccount($name);
$getac2 = $bitcoin->getaddressesbyaccount("hello");
$getac3 = $bitcoin->getaddressesbyaccount(hello);

print_r($getac1);
print_r($getac2);
print_r($getac3);
print_r($name);
echo "</pre>";
?>

```

**Tags:** bitcoind, bitcoin-core-accounts

> **Comments:**
> **username_1**: Welcome to Bitcoin.SE! I will have a look at your question and see if I can come up with an answer.  

---

## 1 answers

### Answer by username_1 on 2018-02-09. Score: 1

This looks like a subtle issue with the code you are using and I do not think you are taking a sensible approach to getting the name back from the input. The javascript will not execute inside of your PHP, it only runs when sent to the browser.

When it executes your function `prompt` is called but the return is everything inside the quotes on line 7, which is not what you typed into the input but is exactly what is inside the quotes:

> ```
> $answer = "<script type='text/javascript'> document.write(answer); </script>";
>
> ```

I should ask, in what mode are you executing or calling your PHP - PHP can be executed standalone or it can execute with a browser page request.

I would solve this in a very rudimentary fashion by creating a HTML form which only displays if some $POST option is not set with the input, setting up the form to post back to the same URL and checking first for the $POST data as said. Then, if the $POST data is set, go ahead and create the output page - all in the one PHP file.

> **Comments:**
> **username_0**: I'm calling PHP with a browser page request. Could you perhaps point me to a direction I can research so I can fix this? I'm pretty new at php so I'm not really sure what I'm doing  

---

