0

I have this PHP code that contacts an external API

$arr = array(
        "domain_name" => $_POST["domain"],
       "auto_renew" => false,
       "domain_lock" => false,
       "whois_privacy" => false, 
       "contact_registrant_id" => $_POST["registrant_contact"], 
       "contact_admin_id" => $_POST["admin_contact"], 
       "contact_tech_id" => $_POST["tech_contact"], 
       "contact_billing_id" => $_POST["billing_contact"], 
       "auth_code" =>($_POST["auth_code"])
    );

The value I am posting for $_POST["auth_code"] is l&"IkM%Wbjjq7

However, when it posts this value, its being posted as l&\\\"IkM%Wbjjq7

So its adding the slashes, which is causing a problem.

charlie
  • 415
  • 4
  • 35
  • 83

2 Answers2

1

it may help you. The "magic_quotes_gpc" might be on.You can disable it in php.ini.

magic_quotes_gpc = Off 

OR 

$str = $_POST["auth_code"];
echo get_magic_quotes_gpc() ? stripslashes($str) : $str;

OR 

echo stripslashes($str);
Sunil kumar
  • 761
  • 5
  • 15
0

This is probably due to magic quotes. See https://stackoverflow.com/a/517027/4275413 and http://php.net/manual/de/security.magicquotes.disabling.php for further details (second link official way to "disable" them).

This once was a good idea to protect the user (read the coder) from himself, when inserting stuff into the database or some other place, by adding escaping by default, which of course ruins almost every script not expecting it.

Community
  • 1
  • 1
Jakumi
  • 8,043
  • 2
  • 15
  • 32