to add some properties to a record (call it product) i use an iframe containing the list of properties and the insertNew form.
Running on Firefox, Opera, Safari it does things right, but IE (explorer) runs the insert query twice.
I firts i check if the relationship product<=>attachement already exists.
then i make some mandatory values check
then if no error exists i run the query.
If i turn the relationship product<=>attachement check off the script insert the record twice, if i turn it on the script inserts the record once and then prompt the "already exists" warning.
I tried to redirect after the insert success witch headers('Location: xxxxxx ') but the problem persists
function req() is a function retrieving and returning $_REQUEST data cleaning it up from sqlInjection
sql_select() is the sql abstraction layer (I'm using persistent connections but the problem remains with non persistent too)
Code: Select all
if(array_key_exists("create_ok",$_POST)){
$query ="SELECT `rowid`,`related_attachement`,`parent_product_id`
FROM `products_related_information`
WHERE `parent_product_id` = '".RELATED_PARENT_PRODUCT_ID."'
AND `related_attachement` = '".process_plain_text(strip_default_folders(req("related_attachement","POST", $sanitise = false)))."'
";
sql_select($query,$results);
if(mysql_num_rows($results)>0){
$error_exists = true;
echo "".translate("exclaim_image")."<strong><span class=\"red\">\" The selected relationship already exits on this database. !!\"</span> ".translate("ammend").".</strong><br><br>";
}
elseif(!trim(req("related_attachement","POST", $sanitise = false))){
$error_exists = true;
echo "".translate("exclaim_image")." <strong><span class=\"red\">\" A Related Attachement MUST be selcted. !!\"</span> ".translate("ammend").".</strong><br><br>";
}
elseif((trim(req("related_attachement","POST", $sanitise = false)))&&(!this_file_exists(req("related_attachement","POST", $sanitise = false),"../".DOCUMENTS_FOLDER))){
$error_exists = true;
echo "".translate("exclaim_image")." <strong><span class=\"red\">\" The attachement file doesn't exists !!\"</span> ".translate("ammend").".</strong><br><br>";
}
elseif((trim(req("related_attachement","POST", $sanitise = false)))&&(!trim(req("related_attachement_title","POST", $sanitise = false)))){
$error_exists = true;
echo "".translate("exclaim_image")." <strong><span class=\"red\">\" A Title for the attachement file in mandatory !!\"</span> ".translate("ammend").".</strong><br><br>";
}
else{
$error_exists = false;
//////start query
$create_att_query = "INSERT IGNORE INTO `products_related_information`
(
`parent_product_id`,
`related_attachement`,
`related_attachement_title`,
`related_attachement_language_id`,
`update_date`,
`last_editor`
)
VALUES
(
'".RELATED_PARENT_PRODUCT_ID."',
'".process_plain_text(strip_default_folders(req("related_attachement","POST", $sanitise = false)))."',
'".process_plain_text(req("related_attachement_title","POST", $sanitise = false))."',
'".process_plain_text(req("language_id","POST", $sanitise = false))."',
NOW(),
'".$_SESSION[LOCAL_IDENTIFIER.'_CURRENT_ADMINISTRATOR_ID']."'
)";
if(sql_select($create_att_query,$create_att_results)){
echo "<strong class=\"green\">".translate("attachement")." <span class=\"grey_strong\">".stripslashes(process_plain_text(strip_default_folders(req("related_attachement","POST", $sanitise = false))))."</span> ".translate("created_successfully").".</strong><br><br>";
}
else{
echo "<strong class=\"red\">ERROR-Database error</strong><br>".$_SESSION[LOCAL_IDENTIFIER.'_DB_ERRORS']."<br><br>";
}
}
}