ik ben geen php-expert, maar dit zou je erdoorheen moeten helpen:
Wijzig eerst het formuliergebied op de hoofdpagina:
<div class="form_style">
<textarea name="content_txt" id="contentText" cols="45" rows="5"></textarea><br/>
<input type="text" id="balance" /><br/>
<input type="text" id="acctNum" /><br/>
<input type="text" id="monthly" /><br/>
<button id="FormSubmit">Add record</button>
</div>
dan ziet uw myData er als volgt uit:
var myData = {
content_txt: $("#contentText").val(),
balance: $("#balance").val(),
acctNum: $("#acctNum").val(),
monthly: $("#monthly").val()
};
en later in de ajax-reactie:
$("#contentText").val(''); //empty text field after successful submission
$("#balance").val('');
$("#acctNum").val('');
$("#monthly").val('');
en tot slot de PHP:
//sanitize post value, PHP filter FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH
$content = filter_var($_POST['content_txt'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$balance = filter_var($_POST['balance'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$account = filter_var($_POST['acctNum'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$monthly = filter_var($_POST['monthly'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$qry= "INSERT INTO add_delete_record(content,balance,account,monthly) VALUES('".$content."','".$balance."','".$account."','".$monthly."')";
// Insert sanitize string in record
if(mysql_query("INSERT INTO add_delete_record(content,balance,account,monthly) VALUES('".$content."','".$balance."','".$account."','".$monthly."')"))
{
//Record is successfully inserted, respond to ajax request
$my_id = mysql_insert_id(); //Get ID of last inserted record from MySQL
echo '<li id="item_'.$my_id.'">';
echo '<div class="del_wrapper"><a href="#" class="del_button" id="del-'.$my_id.'">';
echo '<img src="images/icon_del.gif" border="0" />';
echo '</a></div>';
echo $content.'</li>';
mysql_close($connecDB);
}else{
//output error
//header('HTTP/1.1 500 '.mysql_error());
header('HTTP/1.1 500 Looks like mysql error, could not insert record!');
exit();
}