angelcause Posted September 24, 2013 Share Posted September 24, 2013 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. <?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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/282408-php-values-replacement-from-fields/ Share on other sites More sharing options...
Ch0cu3r Posted September 24, 2013 Share Posted September 24, 2013 (edited) By fields do you form fields in a webpage? You can get the values from submitted form fields using $_POST superglobal variable, so long as the form is using the post method. Example form code <form method="post"> Dst_nbr: <input type="text" name="dst_nbr" /><br /> Message: <input type="text" name="message" /><br /> <input type="submit" name="submit" value="submit" /> </form> <?php if(isset($_POST['submit'])) { $dst_nbr = $_POST['dst_nbr']; $message = $_POST['message']; echo 'You posted<br />Dsn_nbr =' . $dst_nbr . '<br/>Message = ' . $message; } Edited September 24, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282408-php-values-replacement-from-fields/#findComment-1451029 Share on other sites More sharing options...
angelcause Posted September 24, 2013 Author Share Posted September 24, 2013 Yes, What will be the code for posting the fields to the PHP Code (The file name of the PHP Code is submit.php) Quote Link to comment https://forums.phpfreaks.com/topic/282408-php-values-replacement-from-fields/#findComment-1451040 Share on other sites More sharing options...
Ch0cu3r Posted September 24, 2013 Share Posted September 24, 2013 (edited) You'd set the form action attribute to submit.php ie: <form action="submit.php" method="post"> When the forms submit button is pressed the form will go to submit.php with the information entered in the form. Then in submit.php change <Dst_nbr>923665487745</Dst_nbr> <Mask>STAFF</Mask> <Message>"A task is due, Please check your email or Login into the Dashboard."</Message> To <Dst_nbr>'.$_POST['dst_nbr'].'</Dst_nbr> <Mask>STAFF</Mask> <Message>"'.htmlentities(strip_tags($_POST['message']), ENT_QUOTES).'"</Message> Edited September 24, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282408-php-values-replacement-from-fields/#findComment-1451057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.