Jump to content

Save to mysql and show text while typing onkeypress


xcislav

Recommended Posts

The idea is simple. A key you press (a letter) appears in updated page:

keyj.php:

<input id='k'></input>
<script type="text/javascript">
document.getElementById('k').onkeypress=function()
{
<?php
$db=new PDO('mysql:host=localhost;dbname=test;charset=utf8','$us','$ps');
$db->exec("UPDATE TXT SET texts=k.value");
$rl=$db->query("SELECT texts FROM TXT");
print_r($rl->fetchColumn());
?>
}
</script>

The intention is to have text on the screen via print_r. I successfully used it in another php to exchange information with MySQL and users screen (worked).
Here - the more you type and the more k.value is the more text will be on screen (just from server).

Unfortunately something went wrong.
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.