Hi, I m new in this field. Actually I face a problem, I call a php file from a html file using javascript. I declare a variable in php file,I want to use this variable in the same html file after execution of php file.Please help.

i think you can't use a php variable in a html file...
If you want send some value from php file to html file, then put it in hidden variable at php file , and send it to html file..

Hi, I m new in this field. Actually I face a problem, I call a php file from a html file using javascript. I declare a variable in php file,I want to use this variable in the same html file after execution of php file.Please help.

Add .htaccess file to your directory

Inside the .htaccess file input :

AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .php .htm

This should allow you to use php in your .html files

If you're using JavaScript to call a PHP file, then it sounds like AJAX. In which case you would have to use the DOM to display the result of the PHP script. Please show us the script you're using.

i think you can't use a php variable in a html file...
If you want send some value from php file to html file, then put it in hidden variable at php file , and send it to html file..

Thank Shanti. Can u explain how can i use hidden variable in php.

If you're using JavaScript to call a PHP file, then it sounds like AJAX. In which case you would have to use the DOM to display the result of the PHP script. Please show us the script you're using.

Thanks.
window.location.href = "loginCheck.php?idValue=" + idValue;
I use this code to pass a single value, how can i pass more than one value?

you can pass more than one value by the following way,
window.location.href = "loginCheck.php?idValue=" + idValue+"&idvalue1="+idvalue1;

Thank Shanti. Can u explain how can i use hidden variable in php.

see this example:

b>TicTacToe</b><br>
Enter Move X.<br>
<pre>
<form action="tictactoe.php" method="GET">
<input type="text" name="move" size=2>
  0|x|2    <br>
  _|_|_    <br>
  3|4|o    <br>
  _|_|_    <br>
  6|7|8    <br>
</pre>
<input type="hidden" name="board" value="0x234o678">
</form>

see this example:

b>TicTacToe</b><br>
Enter Move X.<br>
<pre>
<form action="tictactoe.php" method="GET">
<input type="text" name="move" size=2>
  0|x|2    <br>
  _|_|_    <br>
  3|4|o    <br>
  _|_|_    <br>
  6|7|8    <br>
</pre>
<input type="hidden" name="board" value="0x234o678">
</form>

thank u. i get it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.