I have embeded a button in my web that submits a search. The search value of this form is inputed from a txt
file by a php code
. The problem I have is that this php code
its loaded only once when the webpage loads. This is a problem because the txt
file is constantly changing and its content gets read only that first time. So what I want is to make the search value to be inputed when the submit button gets clicked. In other words, I'm looking to make the php code
to run and fill the search value onClick.
Here's the form:
<form id="search" action="http://www.example.com/search.php" method="get" target="_blank">
<input type="hidden" name="search" value="<?php $file = "http://www.clavederock.com.ar/zararadio/CurrentSong.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$line = preg_replace("/-(.*?)-/", "", $line);
print $line;}?>"/>
<input type="hidden" name="language" value="es"/>
<input type="image" src="img/psue.png">
</form>
Any suggestion or help will be aprecciated!! Thanks!
EDIT: I see php gets executed before the page is delivered because is server side scripting. To make a workaround this problem, is there a way to make the php code
run every x seconds? Like you would make in a div:
setInterval(function(){
$('#ID').load('example.php');
}, 10000);