marbles Posted April 2, 2007 Share Posted April 2, 2007 recently signed up for a text messageing service that can use php script to send required details to specific mobile numbers, Anyways i recieved this code from the company: Send Using PHP <?php //set up variables $info = "1"; $address = "www.txtlocal.com/sendsmspost.php"; $message = "Hello this is a test with an ampersand (&) and a £5 note"; $message = urlencode($message); //encode special characters (e.g. £,& etc) $from = "Jims Autos"; $uname = "youremailaddress"; $pword = "yourpassword"; $selectednums = "447740101098"; //build url $data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info; //send messages $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$address"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec ($ch); curl_close ($ch); ?> The areas of code that i have underlined above are the values that i wish to enter via a webbased form. Please help i have been trying all day using bits of codes from different websites but have had no joy! Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/ Share on other sites More sharing options...
phoenixx5 Posted April 2, 2007 Share Posted April 2, 2007 on your form page use this code: <form method="POST" action="http://www.txtlocal.com/sendsmspost.php"> <input type="text" name="usermessage" size="20"><br> <input type="text" name="userselectednums" size="20"><input type="submit" value="Submit" name="B1"><br> </form> on the code you posted change the following: $message = ($usermessage); $selectednums = ($userselectednums); that should do it. let me know how it comes out. Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220108 Share on other sites More sharing options...
marbles Posted April 2, 2007 Author Share Posted April 2, 2007 should i keep the php script and the form script on the same page? Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220113 Share on other sites More sharing options...
phoenixx5 Posted April 2, 2007 Share Posted April 2, 2007 You can by using ISSET, but for debugging purposes I would keep them as separate pages. Or you can pu the vendor supplied code into a .inc file and call it when needed... this way if you want to use on various pages in your site, you can just change the .inc file one time and your done. Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220132 Share on other sites More sharing options...
marbles Posted April 2, 2007 Author Share Posted April 2, 2007 its not working man. Heres my code from start to finish for the form page: (PS....SHOULD I SAVE THIS as .HTM or .PHP) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <form method="POST" action="http://www.txtlocal.com/sendsmspost.php"> <input type="text" name="usermessage" size="20"><br> <input type="text" name="userselectednums" size="20"><input type="submit" value="Submit" name="B1"><br> </form> </body> </html> My PHP code looks like this in full: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <?php //set up variables $info = "1"; $address = "www.txtlocal.com/sendsmspost.php"; $message = ($usermessage); $from = "watersideCU"; $uname = "ihavemyusernamehere"; $pword = "ihavemypasswordhere"; $selectednums = ($userselectednums); //build url $data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info; //send messages $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$address"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec ($ch); curl_close ($ch); ?> <body> </body> </html> I can see one problem with it how does my form page know to relate to my php page? Please help!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220152 Share on other sites More sharing options...
marbles Posted April 2, 2007 Author Share Posted April 2, 2007 can anyone help? Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220167 Share on other sites More sharing options...
trq Posted April 3, 2007 Share Posted April 3, 2007 the complete php script need only be... <?php $info = "1"; $address = "www.txtlocal.com/sendsmspost.php"; $message = ($_POST['usermessage']); $from = "watersideCU"; $uname = "ihavemyusernamehere"; $pword = "ihavemypasswordhere"; $selectednums = ($_POST['userselectednums']); $data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$address"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec ($ch); curl_close ($ch); ?> Link to comment https://forums.phpfreaks.com/topic/45331-need-help-with-php-webpage-and-form-on-webpage/#findComment-220227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.