Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP form with Javascript
    text
    copied!<p>Been trying editing a script i found in W3 school.</p> <p>Edit: I want to have a search text box. I can enter data in it and it will trigger the PHP script and return the value without reloading the homepage. So when i enter "404040" and click search button it should do this adminsearchvip.php?q=404040 then return the value without reloding the homepage. end of edit.</p> <p>The original script is a dropdown menu but i want a textboxt insted.</p> <p>I am not sure if the code for the send "Submit" button is correct.</p> <p>First file searchvip.php</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;script&gt; function showUser() { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","adminsearchvip.php?q="+str,true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;label for="Number"&gt;&lt;/label&gt; &lt;input type="text" name="Number" id="Numbers" value=""&gt; &lt;input type='button' onclick='showUser(Numbers.value)' value='Search' /&gt; &lt;/form&gt; &lt;br&gt; &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And the script it self.</p> <p>adminsearchvip.php</p> <pre><code>&lt;?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','xxxxxx','xxxxx','jossan'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"jossan"); $sql="SELECT * FROM vip_stat WHERE code = '".$q."'"; $result = mysqli_query($con,$sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;Number&lt;/th&gt; &lt;th&gt;Bought Date&lt;/th&gt; &lt;th&gt;Type&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;Used&lt;/th&gt; &lt;th&gt;Activation Date&lt;/th&gt; &lt;th&gt;Username&lt;/th&gt; &lt;/tr&gt;"; while($row = mysqli_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['number'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['time'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['type'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['Price'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['used'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['utime'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['username'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; mysqli_close($con); ?&gt; </code></pre> <p>I have tested to go the www.homepage.com/adminsearchvip.php?q=9494943 with my webbrowser and that works i get the correct respons. So the script seems to work. But the search page does not even show anything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload