ritwick Posted February 29, 2008 Share Posted February 29, 2008 Hi, I have simple module for submitting a form data and printing it. The problem is, if there is any occurrence of backslash in the form data, it is doubled! i.e. there are two backslashes instead of one in the received data. I've tried inserting set_magic_quotes_runtime = 0; , but still have the problem. Thanks in advance. - Ritwick The form source: <form name="seldir" id="seldir" action="./add_pages.php" method="post"> <input type="hidden" name="parent_dir" id="parent_dir" value="\admin"> </form> The PHP value catching code in (add_pages.php) : print 'PARENT: '.($_POST['parent_dir']); The PHP output: PARENT: \\admin Quote Link to comment Share on other sites More sharing options...
conker87 Posted February 29, 2008 Share Posted February 29, 2008 Hmm, try adding an extra backslash in your value there. <input type="hidden" name="parent_dir" id="parent_dir" value="\\admin"> Quote Link to comment Share on other sites More sharing options...
ritwick Posted February 29, 2008 Author Share Posted February 29, 2008 Thanks Conker87 for your suggestions. But I get the out put for: <input type="hidden" name="parent_dir" id="parent_dir" value="\\admin"> as PARENT: \\\\admin Quote Link to comment Share on other sites More sharing options...
conker87 Posted February 29, 2008 Share Posted February 29, 2008 Blegh! If you're value is a directory, shouldn't you be using forward slashes (/) anyway? Quote Link to comment Share on other sites More sharing options...
conker87 Posted February 29, 2008 Share Posted February 29, 2008 Just ignore that. Just realised what I posted. It's abit of a pickle that, have you tried using stripslashes()? Other than that I'm totally perplexed (might be because I stuck at work bored!) Quote Link to comment Share on other sites More sharing options...
ritwick Posted February 29, 2008 Author Share Posted February 29, 2008 Nevermind. I've used a bruteforce approach and now my code works correctly after modifying the PHP into: $pardir= trim($_POST['parent_dir']); $pardir= str_replace('\\\\','\\',$pardir); print $pardir; Thanks again for your prompt reply friend! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.