As Always i am back with some other requirement understanding.
point 1: I have below php script to delete the user
Code:
<?php
session_start();
include_once "C:/xampp/htdocs/mym/include/database.php";
$myusername = $_SESSION['myusername']; //user who updating
$user= $_REQUEST['ticket'];
echo '$user';
$sql = ("DELETE FROM $tbl_name1 WHERE ticket='$user'")or die(mysql_error());
if(mysql_query($sql))
{
echo 'Successfully deleted user !!!'
header("location: test.php") or die("record not inserted");
}
mysql_close();
?>
point 2:
I have below jquery script for stylish alert which will invisible after 3 seconds.
Code:
$(document).ready(function() {
$('#demo13').click(function() {
$.blockUI({
theme: true,
title: 'This is your title',
message: '<p>This is your message.</p>',
timeout: 2000
});
});
});
Now I want to use the Jquery script in the PHP exactly in the place of "echo 'Successfully deleted user !!!'" in the above script.
can any one please help me understand if this can be possible or any other way coz...when i see Jquery it has more fancy thing and I want some of them to be included on my site .......but, I am newbie to Jquery and beginner with PHP so,I am finding hard time to work on them, please he me in this regards .
I will be waiting for your answers. Also I will be searching for some solution around in the Google....
Regards,
nani
Last edited by nani_nisha06; 11-09-2012 at 07:49 PM..
A good practise is to use output buffering to prevent any headers problems. It helps as you can modify headers even after sending content.
At the very top of your PHP scripts add:
PHP Code:
<?php
ob_start();
?>
At the very bottom add:
PHP Code:
<?php
ob_end_flush();
?>
You can then echo out stuff wherever you want whenever you want as it's all stored in a variable and sent to the browser after the whole script is parsed. In contrast, without them, echoing causes a reply header to be sent which will cause any session_start() or header() to not work at all.
After header(), add exit() or die() to stop execution of the rest of the script.
PHP Code:
if(mysql_query($sql)) { echo 'Successfully deleted user !!!' header("location: test.php") or die("record not inserted"); exit(); }
__________________
For professional Hosting and Web design.....
...
echo 'Successfully deleted user !!!'
header("location: test.php") or die("record not inserted");
..,
It won't work
You will not see the message because of the immediate redirect.
If you want to redirect with php, I suggest you to put the message into session and then show it after redirect.
It won't work
You will not see the message because of the immediate redirect.
If you want to redirect with php, I suggest you to put the message into session and then show it after redirect.
The ouptut buffering was only a solution to the annoying "HEADERS HAVE ALREADY BEEN SENT" error. And yeah, to see the message you should store it in a session variable. Remove the message to be echoed. Or you can echo the message in the exit() then redirect after some time. Like this: