AJAX HTML PHP question
Posted
by Jordan Pagaduan
on Stack Overflow
See other posts from Stack Overflow
or by Jordan Pagaduan
Published on 2010-04-27T16:17:27Z
Indexed on
2010/04/27
16:23 UTC
Read the original article
Hit count: 341
This is my scripts.js
function showHint(str) { if (str.length==0) { 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 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","inputProcess.php?q="+str,true); xmlhttp.send(); }
This is my HTML
<script type="text/javascript" src="scripts.js"></script> <form> Type your name here : <input type="text" onkeypress="showHint(this.value)" name="name" /> </form>
This is my PHP file
<?php
$q = $_GET['q'];$dbc=mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db('input_oop') or die (mysql_error()); $sql = "INSERT INTO users set name = '".$q."'"; mysql_query($sql) or die (mysql_error()); ?>
When the text is save in my database it will save 5 times or up.
© Stack Overflow or respective owner