Web Analytics Made Easy -
StatCounter need help with this script - CodingForum

Announcement

Collapse
No announcement yet.

need help with this script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • need help with this script

    Hi,
    this is a part of a script I'm using to send url to an sms gateway.

    Code:
    $param["username"] = "[email protected]";
    $param["password"] = "12345";
    $param["msg"] = "This is sample message.";
    $param["to"] = "2348023555555";
    $param["from"] = "MyCompany";
    
    foreach($param as $key=>$val){
    	//this is to urlencode the values
    	$request.= $key."=".urlencode($val);
    	//append the ampersand (&) sign after each paramter/value pair
    	$request.= "&";
    }
    //remove the final ampersand sign from the request
    $request = substr($request, 0, strlen($request)-1);
    my problem is with the username which is an email address, after the encoding the username appears as "%40" in the url that is sent. Is there a way I can prevent this so that it retains the "@" symbol in the resulting $request

  • #2
    Replace
    PHP Code:
    $request.= $key."=".urlencode($val); 
    With
    PHP Code:
    if($key != 'username'){
      
    $request.= $key."=".urlencode($val);

    Comment


    • #3
      Thanks for the reply, but that will take out the username from the result... I'm not trying to take out the username but rather make it display the "@" symbol and not the encoded "%40"
      the result should be this:
      [email protected]&password=12345&msg=This+is+sample+message.&to=234802888888&from=MyCompany

      and not this:
      username=test%40yahoo.com&password=12345&msg=This+is+sample+message.&to=2348028888&from=MyCompany

      hope it's clearer

      Comment


      • #4
        oops, I meant to say replace it with this
        PHP Code:
        if($key == 'username'){
          
        $request.= $key."=".$val;
        }
          
        $request.= $key."=".urlencode($val); 

        Comment


        • #5
          Originally posted by Nightfire View Post
          oops, I meant to say replace it with this
          PHP Code:
          if($key == 'username'){
            
          $request.= $key."=".$val;
          }
            
          $request.= $key."=".urlencode($val); 

          Thanks a lot...didn't need to be encoded...how come I didn't see that?

          Comment


          • #6
            but here's another challenge at the end. I av this function at the end of the curl, to output the response from the sms server:

            curl_exec($ch)

            The sms sever responds with a 4-digit code, depending on the response...but I wish to display something else...eg.

            if the response is 1900, I want to display "Message sent successfully".

            I've tried if...elseif, doesn't give what I want...another help please

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎