it will go to your post.php page before it will perform the onsubmit function
try staying on the same page and using include in you post.php
like
if ($_POST[submit]){
include "post.php";
echo "<script>return checkContentForm(document.writeYourAd);</script>";
}
or you can remove the action, then send your post before or after the checkContentForm() function using ajax
<form name="writeYourAd" id="writeYourAd" method="post" action="" onsubmit="return SendQuery(this);" enctype="multipart/form-data">
JavaScript:
function SendQuery(myForm)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="post.php";
url=url+"?action=preview";
thisForm = myForm;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged(){
if (xmlhttp.readyState==4){
if (xmlhttp.status == 200){
return checkContentForm(thisForm);
}
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
Just Check for some errors.