PHP Get values from Fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
angelcause
Forum Newbie
Posts: 2
Joined: Tue Sep 24, 2013 6:57 am

PHP Get values from Fields

Post by angelcause »

Hello,
Below is my code I am using from a Gateway for sending SMS.

I have 2 felds Dst_nbr and Message, Now the problem is that how can I get values from fields (Dst_nbr and Message) into the values of <Dst_nbr> and <Message> of the code which you can see below.

Currently you can see that the Destination Number code value is 923665487745 and Message is "A task is due, Please check your email or Login into the Dashboard.".

I want it to get the values from the fields of Dst_nbr and Message, So that it can change accordingly to the data entered or available in the fields.


Code: Select all

<?php
set_time_limit(0);
//URL to call
define('ZONG_DOMAIN_URL', "http://115.186.182.11/CSWS/Service.asmx?wsdl"); 
$post_data='<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
 <soap12:Body>
<SendSMS xmlns="http://tempuri.org/">
<Src_nbr>923189377654</Src_nbr>
 <Password>mikeishere</Password>
 <Dst_nbr>923665487745</Dst_nbr>
 <Mask>STAFF</Mask>
 <Message>"A task is due, Please check your email or Login into the Dashboard."</Message>
 <TransactionID>'.rand().'</TransactionID>
</SendSMS>
 </soap12:Body>
</soap12:Envelope>';

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,            ZONG_DOMAIN_URL );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,           1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,     $post_data ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: application/soap+xml', 'charset=utf-8')); 
   echo $result = curl_exec ($ch); 

?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Get values from Fields

Post by Celauran »

Use variables?

Code: Select all

$post_data = 'bla bla bla
...
<Dst_nbr>' . $some_var . '</Dst_nbr>
... etc';
angelcause
Forum Newbie
Posts: 2
Joined: Tue Sep 24, 2013 6:57 am

Re: PHP Get values from Fields

Post by angelcause »

Yes, What will be the code for posting the fields to the PHP Code (The file name of the PHP Code is submit.php)
priyankagound
Forum Commoner
Posts: 27
Joined: Thu Sep 19, 2013 2:53 am

Re: PHP Get values from Fields

Post by priyankagound »

One solution is mysql_fetch_field — Get column information from a result and return as an object.

object mysql_fetch_field ( resource $result [, int $field_offset = 0 ] )

Returns an object containing field information. This function can be used to obtain information about fields in the provided query result.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Get values from Fields

Post by Celauran »

angelcause wrote:Yes, What will be the code for posting the fields to the PHP Code (The file name of the PHP Code is submit.php)
I don't have enough information to answer that. Where are these fields? In a form? In a database?
Post Reply