Magic Quotes and Strip Slashes: What am I doing wrong?
Moderator: General Moderators
Magic Quotes and Strip Slashes: What am I doing wrong?
Hi--
Last edited by eabigelow on Wed Oct 21, 2009 4:55 pm, edited 2 times in total.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Is that all of the code?Here is the code from the add.phtml file:
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
?>
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Hi, many thanks for replying!
Yes, this is all the code for the add.phtml file.
Yes, this is all the code for the add.phtml file.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Whoops! Except for the <?php at the beginning!
Sorry!
Sorry!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
register_globals and magic_quotes... wonderful...
Code: Select all
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Wow! I will try this right away. Many, many thanks (I am keeping my fingers crossed)!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Well, no go on this one so far. I cut and pasted your code into the add.phtml page and uploaded that, but nothing is showing.
I checked to make sure, and here is what I have in my www folder:
php_flag magic_quotes_gpc on
So it appears magic quotes is on. Also, my sever is running PHP 5.XX
Should I have the .htaccess file in the same folder as the add.phtml file?
I checked to make sure, and here is what I have in my www folder:
php_flag magic_quotes_gpc on
So it appears magic quotes is on. Also, my sever is running PHP 5.XX
Should I have the .htaccess file in the same folder as the add.phtml file?
Last edited by eabigelow on Tue Oct 13, 2009 11:27 pm, edited 1 time in total.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Actually, now the inputted text is not showing on the msg.dat page at all... CHMODing file now...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
No text is saving into the msg.dat file at all... CHMOD of add.phtml file at 777. Also tested with original file, and that works (at least for sending the text into the msg.dat file)...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
What's add.phtml now? There's a parse error in it.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Hi--
Sorry for the delay in responding.
Here is the current code in the add.phtml file:
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>
Does this help?
Many thanks!
Sorry for the delay in responding.
Here is the current code in the add.phtml file:
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>
Does this help?
Many thanks!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
I still don't see it.
Change the <?php to be just ?php. This will mean the page won't work and will display as HTML instead, but it'll give a clearer picture as to what exactly is in the file.
Change the <?php to be just ?php. This will mean the page won't work and will display as HTML instead, but it'll give a clearer picture as to what exactly is in the file.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Hi--
hold on... working on this...
hold on... working on this...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Ok--
Some good news!
With your script (as follows) the slashes are stripped from the first two text items, but not the last two (pseudo2, pseudo3). Added: Just tried again--this time, it worked for the first two, and the last, but not the third (pseudo2).
Here's the current add.phtml code:
I thank you for this good first step! Is there any reason why we may be missing some of the text items?
Some good news!
With your script (as follows) the slashes are stripped from the first two text items, but not the last two (pseudo2, pseudo3). Added: Just tried again--this time, it worked for the first two, and the last, but not the third (pseudo2).
Here's the current add.phtml code:
Code: Select all
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Why not just turn of magic quotes? :/