Jump to content

magic_quotes


logicopinion

Recommended Posts

hello everybody, i am trying to create simple cms (content menegment system) and now i am on the run to make something Like :

 

Discription:

 

i have a form with rich text editor, which has to fields, one where is specify page name and another TEXTAREA where i write everything i want to be desplayed on that page so, Code Looks Like this

 

This is The HTML Form With RTE (rich Text Editor)

 

<?php

require("includes/vars.php");
mysql_connect("$hostname", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
print "<table  class='titles' align='center' border='0' cellpadding='0' cellspacing='0' width='500'>";
print "<form name='myform' onsubmit='return submitForm();' action='newpage.php' method='post'>";
print "<tr><td>";
print "Choose page ID<hr />";
print "<select name=\"filename\">";
$query = "SELECT * FROM menu ORDER BY id ASC";
$result=mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{

echo "<option>".$row['id']."</option>";

}

?>

</select>
<hr />

page content
<hr />
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {

updateRTE('rte1'); 
//updateRTEs(); 

return true;
}

//Usage: initRTE(imagesPath, includesPath, cssFile)
initRTE("images/", "", "");
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', 'შეიყვანეთ სასურველი ტექსტი', 400, 200, true, false);
//-->
</script>
</label>
</fieldset>
<br>
<center><input type="submit" value="გაგზავნა">  <input type="reset" value="გასუფთავება..."></center>


</form>

 

and this is the code which gets posted Data and creates page:

 

<?php

$filename = $_POST['filename'];
$rte1 = $_POST['rte1'];
$name = "$filename.php";
$content = fopen("../navigation/".$name, 'w') or die("can't open file");
$stringData = "$rte1";
fwrite($content, $stringData);

?>

 

 

so everything goes fine until it comes to desplay some Styles on that page..

 

when i make some text bold and then see the code in RTE it looks like this:

 

<span style="font-weight: bold;">This is Bold Text</span>

 

and when i go to Navigation folder where this file must be i open it and see lil differance, it adds \ in front of evry " sign and code looks like this

 

<span style=\"font-weight: bold;\">This is Bold Text</span>

 

hope you see the differance,

 

 

please can someone give me some edvice about why this happens,

 

 

maybe u ask so what happens when \ sign is added, tell you if i use this sign no style is applied to text, when i remove them then text looks like as it should be.

 

 

thank you

 

Link to comment
https://forums.phpfreaks.com/topic/78798-magic_quotes/
Share on other sites

thank you guys, can someone show me example with my code i wrote above, i am realy new in php and cant get where to put stripslashes or htmlspecialcharacters, thank you

 

A guide.

$rte1 = $_POST['rte1'];

to

$rte1 = htmlspecialchars(stripslashes($_POST['rte1']));

 

Read a tutorial if you need more help.

 

 

Link to comment
https://forums.phpfreaks.com/topic/78798-magic_quotes/#findComment-398789
Share on other sites

but if i use htmlspecialcharacters it ignores all html tags created by RichText Editor, then how can i apply some style to text? if i ignore all html from it? forexample i want to make text BOLD somewhere in the text, when i use HTMLSPECIALCHARACTER, <B> tag is ignored and i get simple text, but i want to be bold when i make it?

 

is there any other way to apply style then ? i think no

Link to comment
https://forums.phpfreaks.com/topic/78798-magic_quotes/#findComment-398801
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.