Hello,
I am trying to do something very simple, why this will not work is totally beyond me, many of the other threads I have read deal with external form handlers, I would like to have it consolidated into one. Here is my code, please help! Thanks in advance.
The below code should submit the "title" into the database, for some reason, no matter how much I change it around or what I try, It keeps giving me the error message.
Thank you for your time, and if you have any questions you can ICQ me at 173671871
-Bill
<?php
//Form
function defaultDisplay() {
include ('../header.php');
echo "<form action=\"$SERVER['PHP_SELF']\" method=\"post\">"
."<b>AOR</b> "
."<input type=\"text\" name=\"title\" size=\"50\" maxlength=\"80\"><br>";
echo "<br><br><input type=\"submit\" name=\"op\" value=\"Submit\">"
."<br>(Submit)</form>";
include ('../footer.php');
}
//Add Title to DB
function SubmitStory() {
//Connect to DB
mysql_connect("localhost", "********", "*******") or die("Sorry buddy that failed!"); //The stars were done on purpose
mysql_select_db("audiosla_arc");
$title = mysql_escape_string($_POST['title']);
//Insert Into DB
$query = "INSERT INTO arc_aor (aorid, aortitle) VALUES (NULL, '$title')";
$result = mysql_query($query);
if(!$result) {
echo "There was some sort of error, nice try ass!<br>";
exit();
}
include ('../header.php');
$query = "SELECT * from arc_aor";
$result = mysql_query($query);
$waiting = sql_num_rows($result);
echo "<center><br>You just submitted $waiting To the Database. Thank you!</center>";
include ('../footer.php');
}
//Onsubmit go from one function to the next
switch($op) {
case "Submit":
SubmitStory();
break;
default:
defaultDisplay();
break;
}
?>