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 Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/ 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"> Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/#findComment-479912 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 Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/#findComment-479925 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? Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/#findComment-479940 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!) Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/#findComment-479943 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! Link to comment https://forums.phpfreaks.com/topic/93669-error-receiving-backslash-in-form-data/#findComment-479947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.