472,353 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 69342
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...
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...
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...
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...
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...
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...
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...
1
by: getmeidea | last post by:
Hi, I have a code like this function printDocument(url) { var newWindow = window.open(<url>, '_blank'); newWindow.print(); ...
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 its impossible and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.