Login   Register  
PHP Classes
elePHPant
Icontem

File: clevertext.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gary Hockin  >  "Clevertext" AJAX text box  >  clevertext.php  >  Download  
File: clevertext.php
Role: Application script
Content type: text/plain
Description: PHP executed by AJAX
Class: "Clevertext" AJAX text box
Generate editable text box that is saved with AJAX
Author: By
Last change: Added a security fix.
Date: 8 years ago
Size: 919 bytes
 

Contents

Class file image Download
<?php
// Clevertext db update script.
// Gary Hockin .. gary --at-- garyhockin --dot-- co --dot-- uk
// June 2006

// input stuff
// extract the GET values into variables
extract($_GET);

// connect to database
// obviously remove this if you have a globals file or persistant connection
$host 'localhost';
$uname 'test';
$pass 'test';
$db 'test';
$dbconn mysql_connect($host$uname$pass);
mysql_select_db($db);

$val htmlentities($val);

// do the db update
$q 'UPDATE `'.$table.'` SET `'.$field.'` = \''.$val.'\' WHERE `'.$pk.'` = \''.$pkval.'\'';
$r mysql_query($q) or die(mysql_error());
$result mysql_query($q);


// output
header('Content-Type: text/xml');
header('Pragma: no-cache');
echo 
'<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo 
"<data>\n";
echo 
"<field id='field' name='".$field."' value='".$val."' error='".$error."' />\n";
echo 
"</data>\n";
?>