I have the following code for my simple write.php page where I compile posts for my blog. The problem is, when you click on buttons that insert code with a double quotes (e.g. IMG, A Post), it adds backslashes automatically. You will see what I mean when you try it. Is there a solution for that?
<!doctype html> <html> <head> <title>Write</title> <style type="text/css"> html, body, form { height: 99%; } body { margin: 0; } form { margin: 5px; } input { padding:2px 5px; background: #f7f7f7; border: 1px solid #c1c1c1; } input:hover { background: #eee; } input.clear { float: right; } textarea { margin: 5px 0 0 0; width: 99%; height: 95%; font-family:calibri; } </style> </head> <body> <form action='' method='post'> <input type='submit' name='p-open' value='P' /> <input type='submit' name='p-close' value='/P' /> <input type='submit' name='h2' value='H2' /> <input type='submit' name='h3' value='H3' /> <input type='submit' name='b' value='B' /> <input type='submit' name='i' value='i' /> <input type='submit' name='image' value='IMG' /> <input type='submit' name='link-post' value='A Post' /> <input type='submit' name='link-tut' value='A Tut' /> <input type='submit' name='link-ext' value='A Ext' /> <input type='submit' name='ul-open' value='UL' /> <input type='submit' name='ul-close' value='/UL' /> <input type='submit' name='li-open' value='LI' /> <input type='submit' name='li-close' value='/LI' /> <input type='submit' name='hr' value='HR' /> <input type='submit' name='code' value='CODE' /> <input type='submit' name='html' value='HTML' /> <input type='submit' name='clear' value='Clear' class="clear" /><br /> <textarea name='post' ><?php $post = (isset($_POST['post'])) ? $_POST['post'] : null; if (isset($_POST['p-open'])) { $code = '<p>'; echo $post . $code; } else if (isset($_POST['p-close'])) { $code = '</p>'; echo $post . $code; } else if (isset($_POST['b'])) { $code = '<strong></strong>'; echo $post . $code; } else if (isset($_POST['i'])) { $code = '<em></em>'; echo $post . $code; } else if (isset($_POST['h2'])) { $code = '<h2></h2>'; echo $post . $code; } else if (isset($_POST['h3'])) { $code = '<h3></h3>'; echo $post . $code; } else if (isset($_POST['image'])) { $code = '<p><img class="center" src="/img/posts/2011/12/" width="" height="" title="" alt="" /></p>'; echo $post . $code; } else if (isset($_POST['link-post'])) { $code = '<a href="/post/"></a>'; echo $post . $code; } else if (isset($_POST['link-tut'])) { $code = '<a href="/tutorial/"></a>'; echo $post . $code; } else if (isset($_POST['link-ext'])) { $code = '<a href="" target="_blank"></a>'; echo $post . $code; } else if (isset($_POST['ul-open'])) { $code = '<ul><li>'; echo $post . $code; } else if (isset($_POST['ul-close'])) { $code = '</li></ul>'; echo $post . $code; } else if (isset($_POST['li-open'])) { $code = '<li>'; echo $post . $code; } else if (isset($_POST['li-close'])) { $code = '</li>'; echo $post . $code; } else if (isset($_POST['hr'])) { $code = '<hr />'; echo $post . $code; } else if (isset($_POST['code'])) { $code = '<div class="code-outer"><p class="code-inner">[HTML][/HTML]</p></div>'; echo $post . $code; } else if (isset($_POST['html'])) { $code = '[HTML][/HTML]'; echo $post . $code; } else if (isset($_POST['clear'])) { echo ''; } ?></textarea> </form> </body> </html>Also, a backslash is added for single quotes within the text, e.g. "Let's, I'm".