printed text disappears (ff / ie rendering differences?)
Posted: Sun Sep 14, 2008 12:26 pm
This is sort of the same question I posted a few days ago here (which I thought got solved but it didn't): viewtopic.php?f=2&t=87696
Since I now believe it has nothing to do with a databas issue I post it here instead of continuing the above thread. I hope it's ok and not considered breaking any forum rules or such...
I have the below code. I write an encrypted message to a database. With a password sent in the url I can fetch the text from the database and print it on the screen. As soon as it is printed I want it removed from the database so it can not be fetched and read again.
The below code works perfectly according to the above description in both internet explorer and google chrome, but in firefox the text dont get printed and only removed from the database.
Since it works in ie and chome I guess it might have something to do with how firefox renders pages? Maybe it doesn't print any values before all code is run through and then its too late? I tried inserting ob_flush(), flush() and sleep(5) right after I echo the text. This prints the text even in firefox, however it is removed again as soon as the 5 seconds are over.
Another interesting thing is that it sometimes works in firefox when I write a very short text, such as "ok". However, all tests I've done with longer text (it's enough with the length of the previous sentence) haven't worked.
Anybody with some ideas for a solution?
Any help is very appreciated!
UPDATE: Problem solved here: http://forums.mozillazine.org/viewtopic ... 5#p4486215
Since I now believe it has nothing to do with a databas issue I post it here instead of continuing the above thread. I hope it's ok and not considered breaking any forum rules or such...
I have the below code. I write an encrypted message to a database. With a password sent in the url I can fetch the text from the database and print it on the screen. As soon as it is printed I want it removed from the database so it can not be fetched and read again.
The below code works perfectly according to the above description in both internet explorer and google chrome, but in firefox the text dont get printed and only removed from the database.
Since it works in ie and chome I guess it might have something to do with how firefox renders pages? Maybe it doesn't print any values before all code is run through and then its too late? I tried inserting ob_flush(), flush() and sleep(5) right after I echo the text. This prints the text even in firefox, however it is removed again as soon as the 5 seconds are over.
Another interesting thing is that it sometimes works in firefox when I write a very short text, such as "ok". However, all tests I've done with longer text (it's enough with the length of the previous sentence) haven't worked.
Code: Select all
<?php
$open = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db');
if ($_GET['m'] == "write"){
/**
* Write message to database
*/
$password = md5(uniqid(rand(), true));
mysql_query("INSERT INTO message (message, pass) VALUES (AES_ENCRYPT('" . $_POST["message"] . "','" . $password . "'),'" . md5($password) . "')");
echo "link to message: ?p=" . $password . "";
} elseif (strlen($_GET['p']) >= 1){
/**
* Read message from database
*/
$data = mysql_query("SELECT AES_DECRYPT(message, '" . $_GET['p'] . "') AS decryptedMessage FROM message WHERE pass = '" . md5($_GET['p']) . "'");
$data = mysql_fetch_array($data);
echo $data["decryptedMessage"]; // Prints the message on the screen
} else {
echo "
<FORM METHOD=\"post\" ACTION=\"?m=write\">
<TEXTAREA NAME=\"message\"></TEXTAREA>
<INPUT TYPE=\"submit\">
</FORM>
";
}
/**
* deletePost();
*/
/**
* The below line seems to make the text printed on the screen
* on line 21 above disappear from the screen when using firefox
* but it stays printed on the screen when using ie and chome
*/
mysql_query("DELETE FROM message WHERE pass = '" . md5($_GET['p']) . "'");
mysql_close($open);
?>Any help is very appreciated!
UPDATE: Problem solved here: http://forums.mozillazine.org/viewtopic ... 5#p4486215