473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

execute a url from php page without showing it

Execute a url from php page without showing it.

This is what I have:
Expand|Select|Wrap|Line Numbers
  1. function send_sms($receiver,$content)
  2. {
  3. $logIn = 'raphael';
  4. $pwd = 'pwd';
  5. $clientId = 'rg7U97fH7fUujp';
  6. //$receiver = '238052433258';
  7. //$content = 'Just Testing';
  8. $Type = 'TEXT';
  9. $Sender = 'raphsoft';
  10.  
  11. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  12.  
  13. $_GET["$url");
  14. return
  15. }
  16.  
  17. if
  18. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  19. {
  20. $receiver = $_POST["receiver"];
  21. $content = $_POST["contents"];
  22. $send_now = send_sms($receiver,$content);
  23.  
  24. if (isset($send_now))
  25. {
  26. $_SESSION["msg"] = "You text message has been sent";
  27. }
  28. else
  29. {
  30. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  31. }
  32.  
  33. navigate("sms_success.php");
  34. exit;
  35.  
  36.  
  37. }
  38. ?>
  39.  
Jan 15 '09 #1
11 70588
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. $_GET["$url"];
won't work. $_GET contains the variables present in the url of your current file and the array key for $_GET should be a valid variable name.

to just call the service I guess you should use some of the CURL functions. (PHP: cURL - Manual)

regards
Jan 15 '09 #2
Atli
5,058 Expert 4TB
Hi.

I suggest you try reading this:
PHP: $_GET - Manual

And then this:
PHP: file_get_contents - Manual
And if that fails, you could try this:
PHP: cURL - Manual

And finally, if you plan on staying a member on these forums, you should read this:
FAQ: Posting Guidelines - Bytes
Jan 15 '09 #3
This works but does not hide the url. Please help, it's urgent.
Expand|Select|Wrap|Line Numbers
  1. function send_sms($receiver,$content) 
  2. $logIn = 'raphael'; 
  3. $pwd = 'pwd'; 
  4. $clientId = 'rg7U97fH7fUujp'; 
  5. //$receiver = '238052433258'; 
  6. //$content = 'Just Testing'; 
  7. $Type = 'TEXT'; 
  8. $Sender = 'raphsoft'; 
  9.  
  10. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender"; 
  11.  
  12. navigate("$url"); 
  13.  
  14. if 
  15. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D") 
  16. $receiver = $_POST["receiver"]; 
  17. $content = $_POST["contents"]; 
  18. $send_now = send_sms($receiver,$content); 
  19.  
  20. if (isset($send_now)) 
  21. $_SESSION["msg"] = "You text message has been sent"; 
  22. else 
  23. $_SESSION["msg"] = "Sorry, the message cannot be sent"; 
  24.  
  25. navigate("sms_success.php"); 
  26. exit; 
  27.  
  28.  
  29. ?>
  30.  
Jan 15 '09 #4
Atli
5,058 Expert 4TB
Did you even try either of the methods we suggested?

Both the file_get_contents function and the curl functions are capable of doing what you are asking for.

Don't expect us to simply write the code for you. We wont.
Jan 15 '09 #5
Sorry I did. But if u can't help no problem
Jan 15 '09 #6
Atli
5,058 Expert 4TB
I'm happy to help, but you are going to have to do the heavy lifting mate.

If these two methods didn't work for you, show us what you tried and explain why/how it didn't work.
Error messages and such are always a big help to.

If we knew why those two methods won't working for you, maybe we could suggest alternate solutions.
Jan 15 '09 #7
That is what I did it did not work
Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. //include_once('text_class.php');
  4. function navigate($page) {echo "<script language='javascript'>location='$page';</script>";exit;}
  5.  
  6. function send_sms($receiver,$content)
  7. {
  8. $logIn = 'user';
  9. $pwd = 'pwd';
  10. $clientId = '7f7UHfUp';
  11. //$receiver = '230528332548';
  12. //$content = 'Just Testing';
  13. $Type = 'TEXT';
  14. $Sender = 'user';
  15.  
  16. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  17.  
  18. ///
  19. function curl_get_file_contents($url)
  20.     {
  21.         $c = curl_init();
  22.         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  23.         curl_setopt($c, CURLOPT_URL, $URL);
  24.         $contents = curl_exec($c);
  25.         curl_close($c);
  26.  
  27.         if ($contents) return $contents;
  28.             else return FALSE;
  29.     }
  30.  
  31. curl_get_file_contents("$url");
  32. ///
  33. }
  34.  
  35. if
  36. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  37. {
  38. $receiver = $_POST["receiver"];
  39. $content = $_POST["contents"];
  40. $send_now = send_sms($receiver,$content);
  41.  
  42. if (isset($send_now))
  43. {
  44. $_SESSION["msg"] = "You text message has been sent";
  45. }
  46. else
  47. {
  48. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  49. }
  50.  
  51. navigate("sms_success.php");
  52. exit;
  53. //include_once('http://www.example.net');
  54. //exit;
  55.  
  56.  
  57.  
  58. }
  59. ?>
  60.  
Jan 15 '09 #8
Dormilich
8,658 Expert Mod 8TB
although PHP doesn't complain when you define a function inside another function, it seems to be pointless (when I tried it, the inner function wasn't called)
Jan 15 '09 #9
I have removed the function the other function. But it is not working yet.

Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. //include_once('text_class.php');
  3. function navigate($page) {echo "<script language='javascript'>location='$page';</script>";exit;}
  4.  
  5. function curl_get_file_contents($url)
  6.     {
  7.         $c = curl_init();
  8.         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  9.         curl_setopt($c, CURLOPT_URL, $URL);
  10.         $contents = curl_exec($c);
  11.         curl_close($c);
  12.  
  13.         if ($contents) return $contents;
  14.             else return FALSE;
  15.     }
  16.  
  17. function send_sms($receiver,$content)
  18. {
  19. $logIn = 'user';
  20. $pwd = 'pwd';
  21. $clientId = '7UffUp';
  22. //$receiver = '280433232558';
  23. //$content = 'Just Testing';
  24. $Type = 'TEXT';
  25. $Sender = 'user';
  26.  
  27. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  28.  
  29. ///
  30.  
  31. curl_get_file_contents("$url");
  32. ///
  33. }
  34.  
  35. if
  36. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  37. {
  38. $receiver = $_POST["receiver"];
  39. $content = $_POST["contents"];
  40. $send_now = send_sms($receiver,$content);
  41.  
  42. if (isset($send_now))
  43. {
  44. $_SESSION["msg"] = "You text message has been sent";
  45. }
  46. else
  47. {
  48. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  49. }
  50.  
  51. navigate("sms_success.php");
  52. exit;
  53. //include_once('http://www.example.net');
  54. //exit;
Jan 15 '09 #10
Atli
5,058 Expert 4TB
PHP variables are case-sensitive.
Your $URL in line #9 does not match the parameter $url in line #5.
Try changing that.

Also, your send_sms() function does not return a value. Yet in line #42 you try to check the return value to see if it was successful. You need to add a return value to the function if that is supposed to work.

Add these lines at the top of your script. They will tell you if there are errors in it.
Expand|Select|Wrap|Line Numbers
  1. error_reporting(E_ALL);
  2. ini_set('display_errors', true);
Jan 15 '09 #11
Atli, I tried what you said but did not get the right result. Anyway thank you!
Jan 16 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Metnetsky | last post by:
I'd like to build a function that is executed when someone clicks on an image. Once clicked, I need some parameters passed to a URL which PHP will accept and deal with database connections. ...
6
by: benny | last post by:
Hi, I have a web pageA, that include the javascript, to do some onload event so that it would load another web pageB to perform some onload action. Could I able to load the pageB without...
0
by: Brian Tkatch | last post by:
Been trying to figure out how to show borderless forms indside an MDI Form, without showing the border at all. Given that (in our case) only one such form needs to show at a time, we were able...
4
by: TonyJ | last post by:
Hello! I have a small program that just copy a file and make some checks in main then I just want to inform the user about something by using a MessageBox. I tried to use this in the...
1
by: itsenthil | last post by:
Hi....... I want to print mywebpage in buttonclick control without showing printdialogbox..(i.e withuot user intraction)...the page is submitted directely to the printer .....any way to do...
38
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
0
by: engloon | last post by:
Hi guys. I found this code that read a file then print out. The problem that I'm facing is, I have a lot of files to be printed, so I would like to print without showing the print property menu....
1
by: getmeidea | last post by:
Hi, I have a code like this function printDocument(url) { var newWindow = window.open(<url>, '_blank'); newWindow.print(); setTimeout(<function name>,2000); // code for delaying to...
3
by: krille | last post by:
Hello fellow developers! I want to print from a webpage without showing any kind of dialog. After some research some ppl say it´s impossible and som say it´s not. In fact I have seen it be done...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.