<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" /><title>REBOL Submit Confirmation</title></head>
<body>
<br>
<?php
// Connect to DB
$conn = mysql_connect("localhost", "hidden", "hidden_too");
mysql_select_db("leke_reboldb", $conn);
if (!$conn) {
die("Could not connect to DB: <br />" . mysql_error());
}
echo "Connected to DB successfully <br />";
$word = $_POST[word];
$code = $_POST[code];
$notes = $_POST[notes];
// INSERT data
$sql = "INSERT INTO user_form values ('', '$_POST[word]', '$_POST[code]', '$_POST[notes]')";
if (mysql_query($sql, $conn)) {
echo "<br />Record added as: <br /><br />" . $word . "<br /><br />" . $code . "<br /><br />" . $notes . "<br />";
} else {
echo "Error: Failed to INSERT INTO MySQL <br />";
}
// Writes a new file if file doesn't exist >>>>>>
$fileName = 'http://rebol.pcriot.com/dic/' . $word . '.html';
$new_file_content1 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<title>REBOL Word Index</title>
</head>
<body>';
$new_file_content2 = "\n<?php\n\$word = \"$word\";\n?>\n";
$new_file_content3 = '<h1>$word</h1>
<?php
// Connect to DB
$conn = mysql_connect("localhost", "hidden_again", "hey_guess_what!?");
mysql_select_db("leke_reboldb", $conn);
if (!$conn) {
die("Could not connect to DB: <br />" . mysql_error());
}
echo "Connected to DB successfully <br />";
// create a SQL statment - only selects type $word
$sql = "SELECT * FROM leke_reboldb WHERE word = " . "\'" . $word . "\'";
// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());
// go through each row in the result set and display picked data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$code = $newArray[\'code\'];
$notes = $newArray[\'notes\'];
// echo results on the screen with some formating.
echo "</ br></ br>" . "$code" . "</ br></ br>" . "$notes" . "</ br></ br>";
}
?>
</body></html>';
$handle = fopen($fileName, 'x+');
if (file_exists($fileName)) {
// Do nothing :) zzz
}
else
{
fwrite($handle, "$new_file_content1 . $new_file_content2 . $new_file_content3");
fclose($handle);
}
?>
</body></html>