Posting a values to a website

hi all
 im trying to post a value to a webpage hosted by someone. My problem is the receipint website is not getting my post, im doing it like the code below.
Does anyone see what im doing wrong

$post_to_url = ''; 	
		echo $Response;
		$req = 'number=27795686787&message=testing';
                                          $Message = $_REQUEST['mesg'];
		$MobileNumber = $_REQUEST['num'];		
		//$result = mysql_query($query) or die("Couldn't select infor!55");	
		$ch = curl_init();
		echo $post_to_url;			
		curl_setopt($ch, CURLOPT_URL,$post_to_url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$buffer = curl_exec($ch);
		echo "Result=".$buffer;

Open in new window

Dawie de VilliersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Whats the $Response variable?
And are you getting that $_REQUEST from a form?
Dawie de VilliersAuthor Commented:
this variable $_REQUEST  is fine
my problem is when i post to the other page(its not ours/ on a different website), they dont get my post
well on the first sight you have error in initializing connection with curl. Line 7 from you snippet should look like this:
 $ch = curl_init($post_to_url);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

my mistake... i didn't notice the URL option...
Dawie de VilliersAuthor Commented:
thnaks i will test that
Well if I understood right, you are trying to echo a closed curl session. Once you use
curl_close($ch), it frees all system resources and $ch is also deleted.
Dawie de VilliersAuthor Commented:
140770FC:SSL routines:func(119):reason(252)
im getting this error message if i put an  error handler like this
From what i can hazily remember acout curl  - not touched it for ages... this error if i recall means it's not getting to the url...

so check it resolves, also they could be blocking traffic.
Ray PaseurCommented:
The URL is 404.  Let's get past that first.  Then, if the web service at is expecting a POST method call, you might consider using fsockopen().  Is there any chance they are expecting a GET method call?
Dawie de VilliersAuthor Commented:
thnaks guys the problem was my parameter list isnt working fine, so i added everything in the webadd
i wanted to specify the params on thier own.
Thanks guys
echo "mycellnumber=".$value;
					echo "<br>"."Message=".$SendSMG;
					$SendSMG = urlencode($SendSMG);
					$username = 'test';
					$password = 'test';
					//$number = '27795686787';
					$number = $value;
					$message = 'Testing%20fromweb';
					//$url = "https://www.myadd/XML/send/?username=test&password=test&number=27733218190&message=Testing%20fromweb"; 					$url = "$value&message=$SendSMG"; 		
					$ch = curl_init();
					curl_setopt($ch, CURLOPT_URL, $url);
					//curl_setopt ($ch, CURLOPT_PORT, $port);
					curl_setopt ($ch, CURLOPT_POST, 1);
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
					$post_body = '';
					$post_fields = array(
						username => $username,
						password => $password,
						message => $message,
						msisdn => $number
					foreach($post_fields as $key=>$value) 
						$post_body .= urlencode($key).'='.urlencode($value).'&';
					$post_body = rtrim($post_body,'&');
					curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_body);
					$response_string = curl_exec($ch);

Open in new window

Ray PaseurCommented:
Let me ask this question again: Is there any chance they are expecting a GET method call?  I am asking because you have a URL in the comment on line 9 that looks like a RESTful interface call, made using the GET method.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.