2016-02-25 17 views
0

Kindly go though the link我想顯示警報消息。我的插入是成功的,並且標頭也正常工作,但alert()不起作用。任何幫助,將不勝感激。在php中使用echo的警報

if(mysql_query($query))//query execution 
{ 
    echo '<script language="javascript" type="text/javascript"> '; 
    echo 'alert("message successfully Inserted")';//msg 
    echo '</script>'; 
    header('location:madesignin.php');//header jump to the page 
    exit;  
} 
else//data will be not inserted if condition fails 
{ 
    echo "DATA NOT INSERTED"; 
} 
+0

''''單行寫入。 –

+0

將您的回聲聲明寫入

0

警報將無法在上述情況下工作,因爲重定向和javascript alert()正在調用同一時間。所以它會跳過JavaScript並重定向到頁面。

嘗試

if(mysql_query($query))//query execution 
{ 
echo '<script language="javascript" type="text/javascript"> '; 
echo 'if(!alert("message successfully Inserted")) {';//msg 
echo ' location.href="madesignin.php"'; 
echo '}'; 
echo '</script>'; 
exit;  
} 
else//data will be not inserted if condition fails 
{ 
    echo "DATA NOT INSERTED"; 
}