if(isset($_POST[submit])){
$exclude=array('submit');
$sql ="insert into products set ";
foreach($_POST as $k=>$v){
if(!in_array($k,$exclude)){
$sql_array[]= mysql_real_escape_string($k)." = '".mysql_real_escape_string($v)."' ";
}
}
$sql .= implode(",",$sql_array);
$q=mysql_query($sql) or die(mysql_error());
if($q) {
echo 'Inserted';
}
}
This coding is on iframe inside dialog box. I want to close dialog box after submitting form. How can i do this ?
step 1:
add a js function in parent window which close the iframe
function close_iframe()
{
$('#iframe_id').remove();
}
step 2:
call this js function from iframe when successfully inserted like
if($q){
echo 'Inserted';
?>
<script>
parent.close_iframe();
</script>
<?php
}
you have to do this by using javascript as php cant work on client side. use this after submitting -
echo "<script> window.close(); </script>";
this might work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.