submit-retrieve

The following is a code snippet for doing a post and a retrieve of data in MySQL/PHP.

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">





Menu Retrieve test Retrieve test2
< ?php require_once 'connect_db.php'; $ref = $_REQUEST["ref"]; $sql = "SELECT * FROM xmlstorage WHERE reference=\"${ref}\""; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } $count = 0; while ($dbline = mysql_fetch_object($result)) { $count++; echo $dbline->data; } mysql_free_result($result); mysql_close($db); ?> < ?php require_once 'connect_db.php'; $ref = $_REQUEST["ref"]; $data = $_REQUEST["data"]; $sql = "INSERT INTO xmlstorage (reference, data) VALUES ('${ref}' , '${data}')"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } mysql_close($db); ?> < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

One thought on “submit-retrieve