madhmad Posted May 1, 2011 Share Posted May 1, 2011 i hav this url n whenever i click on this url i get som mssg send on my mobile i hav a form whose code is <form action="formprocess.php method="post"> telephone<input type="text name="telephone> <input type="submit" name="submit"> </form> i want to send telephone as parameter to this url so whenever user enters his telephone he gets d mssg after clicking on submit.....but i hav no idea how to do tht...help me somone plssssssss http://www.abc.in/smsapi/sendsms.php?sendto=9987234123&msg=your Quote Link to comment https://forums.phpfreaks.com/topic/235287-related-with-passing-variables-in-url/ Share on other sites More sharing options...
teddyb Posted May 1, 2011 Share Posted May 1, 2011 You could do it using the form like <html> <head> <title></title> </head> <body> <form action="http://www.abc.in/smsapi/sendsms.php" method="get"> telephone:<input type="text" name="sendto"> message:<input type="text" name="msg"> <input type="submit" name="" value="Send Message"> </form> </body> Or if you want it to go to your own script which then makes the request you would have something like this If curl isnt installed: <?php if (isset($_POST['sendto'])) { $sendto = $_POST['sendto']; } if (isset $_POST['message']) { $message = $_POST['message']; } //Do some validation on input $api_address = "http://www.abc.in/smsapi/sendsms.php" get_headers($api_address.'?'.'sendto='.$sendto.'&msg='.urlencode($message)); if it is <?php if (isset($_POST['sendto'])) { $postdata['sendto'] = $_POST['sendto']; } if (isset $_POST['message']) { $postdata['message'] = $_POST['message']; } //Do some validation on input $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.abc.in/smsapi/sendsms.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_exec($ch); curl_close($ch); I havent tested this code but it *should* /hopefully/ work Quote Link to comment https://forums.phpfreaks.com/topic/235287-related-with-passing-variables-in-url/#findComment-1209168 Share on other sites More sharing options...
madhmad Posted May 2, 2011 Author Share Posted May 2, 2011 hey ur code is fine.....i m able to send sms to the number given by user...but wht i want is tht user doesnt give the mssg on his own...i want to send a random number to the user n tht random number gets stored inmy database as well......so far my code is <html> <head> <title></title> </head> <body> srand ((double) microtime( )*1000000); $random_number = rand( ); <form action="http://www.bluled.in/smsapi/sendsms.php" method="get"> telephone:<input type="text" name="sendto"> message:<input type="text" name="msg"> <input type="submit" name="" value="Send Message"> </form> </body> can u help me wid dis pls Quote Link to comment https://forums.phpfreaks.com/topic/235287-related-with-passing-variables-in-url/#findComment-1209301 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.