A little problem with a script

Thread Solved

Join Date: Jan 2008
Posts: 23
Reputation: tedobg is an unknown quantity at this point 
Solved Threads: 0
tedobg tedobg is offline Offline
Newbie Poster

Re: A little problem with a script

 
0
  #31
Mar 12th, 2008
Hey Guys.Good news.Problem solved.Thank you all for the help and special thanks to Designer_101.I got immediate results after instaling wamp server and now I can continue my work.Users inserted successfully and no blank pages.Thanks again and Peace to you all.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 253
Reputation: Designer_101 is an unknown quantity at this point 
Solved Threads: 12
Designer_101's Avatar
Designer_101 Designer_101 is offline Offline
Posting Whiz in Training

Re: A little problem with a script

 
0
  #32
Mar 12th, 2008
no problem m8. Btw can i ask how old u r...earlier you said you had 2 go 2 school? im 14
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 23
Reputation: tedobg is an unknown quantity at this point 
Solved Threads: 0
tedobg tedobg is offline Offline
Newbie Poster

Re: A little problem with a script

 
0
  #33
Mar 12th, 2008
Designer mate sorry I didn't answer immediately but I was having diner.Well I am 16... PM me later we can talk mate. Right now I am marking this as solved thanks again.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2
Reputation: patel manish is an unknown quantity at this point 
Solved Threads: 0
patel manish patel manish is offline Offline
Newbie Poster

Re: A little problem with a script

 
0
  #34
Dec 19th, 2008
can any buddy help me!!!

this is my php sms sending script but i cant send it.
for sending sms any setting reqire?

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4. <title>Send SMS from your web page</title>
  5. </head>
  6. <body>
  7. <?php
  8.  
  9. $footer = 'Your footer text';
  10. $maxSizeSms = 160 - strlen($footer);
  11.  
  12.  
  13.  
  14. DEFINE('API_USER', 'ts_ravie');
  15. DEFINE('API_PWD', 'rav@34');
  16. DEFINE('API_receipt', 'Yes');
  17. DEFINE('API_sender', 'Ravience');
  18.  
  19.  
  20. // check if form has been "posted"
  21. if( isset($_GET['mobile']) && isset($_GET['sms']) ){
  22.  
  23. // phone number and message (message + footer)
  24. preg_match_all('/[\d]{11}/', $_GET['mobile'], $mobile);
  25. $sms = urlencode(substr($_GET['sms'], 0, $maxSizeSms).$footer);
  26.  
  27. // URL for sending the SMS
  28. $apiCallUrl = 'http://122.169.193.83:8888/?';
  29. $apiCallUrl .= 'User='.API_USER.'&Password='.API_PWD.'&ReceiptRequested='.API_receipt.'&sender='.API_sender;
  30. $apiCallUrl .= '&PhoneNumber='.$_GET['mobile'].'&Text='.$sms;
  31.  
  32.  
  33.  
  34. $curlHandle = curl_init();
  35.  
  36.  
  37. curl_setopt($curlHandle, CURLOPT_URL, $apiCallUrl);
  38.  
  39. curl_setopt($curlHandle, CURLOPT_HEADER, 0);
  40.  
  41. curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
  42.  
  43. curl_setopt($curlHandle, CURLOPT_POST, 1);
  44.  
  45. curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
  46.  
  47. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 15);
  48.  
  49.  
  50. $content = curl_exec($curlHandle); // Make the call for sending the SMS
  51.  
  52. curl_close($curlHandle); // Close the connection to Clickatell
  53.  
  54. if( preg_match('/^ID:/', $content) ){
  55. echo '<h2>Message have been sent</h2>';
  56. }else{
  57. echo '<h2>Error sending message</h2>';
  58. }
  59. }
  60. ?>
  61.  
  62.  
  63.  
  64. <form method="get" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
  65.  
  66. Phone number <br />
  67. <input type="text" name="mobile" size="20" maxlength="12" value="" />
  68. <br />
  69.  
  70. Message <br />
  71. <input type="text" name="sms" size="30" maxlength="<?php echo $maxSizeSms ?>" value="" />
  72.  
  73. <br />
  74.  
  75. <input type="submit" value="Send SMS" />
  76.  
  77. </form>
  78.  
  79. </body>
  80. </html>
Last edited by peter_budo; Dec 21st, 2008 at 3:59 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2
Reputation: patel manish is an unknown quantity at this point 
Solved Threads: 0
patel manish patel manish is offline Offline
Newbie Poster

Re: A little problem with a script

 
0
  #35
Dec 19th, 2008
can any buddy help me!!!

this is my php sms sending script but i cant send it.
for sending sms any setting reqire?
Originally Posted by patel manish View Post

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Send SMS from your web page</title>
</head>
<body>
<?php

$footer = 'Your footer text';
$maxSizeSms = 160 - strlen($footer);



DEFINE('API_USER', 'ts_ravie');
DEFINE('API_PWD', 'rav@34');
DEFINE('API_receipt', 'Yes');
DEFINE('API_sender', 'Ravience');


// check if form has been "posted"
if( isset($_GET['mobile']) && isset($_GET['sms']) ){

// phone number and message (message + footer)
preg_match_all('/[\d]{11}/', $_GET['mobile'], $mobile);
$sms = urlencode(substr($_GET['sms'], 0, $maxSizeSms).$footer);

// URL for sending the SMS
$apiCallUrl = 'http://122.169.193.83:8888/?';
$apiCallUrl .= 'User='.API_USER.'&Password='.API_PWD.'&ReceiptRequested='.API_receipt.'&sender='.API_sender;
$apiCallUrl .= '&PhoneNumber='.$_GET['mobile'].'&Text='.$sms;



$curlHandle = curl_init();


curl_setopt($curlHandle, CURLOPT_URL, $apiCallUrl);

curl_setopt($curlHandle, CURLOPT_HEADER, 0);

curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curlHandle, CURLOPT_POST, 1);

curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);

curl_setopt($curlHandle, CURLOPT_TIMEOUT, 15);


$content = curl_exec($curlHandle); // Make the call for sending the SMS

curl_close($curlHandle); // Close the connection to Clickatell

if( preg_match('/^ID:/', $content) ){
echo '<h2>Message have been sent</h2>';
}else{
echo '<h2>Error sending message</h2>';
}
}
?>



<form method="get" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">

Phone number <br />
<input type="text" name="mobile" size="20" maxlength="12" value="" />
<br />

Message <br />
<input type="text" name="sms" size="30" maxlength="<?php echo $maxSizeSms ?>" value="" />

<br />

<input type="submit" value="Send SMS" />

</form>

</body>
</html>
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: A little problem with a script

 
0
  #36
Dec 22nd, 2008
Originally Posted by tedobg View Post
Hi guys.I am new to web development and of course I have been experiensing some problems.Most of them are easy to solve and I usually find my way, but there is some thing that is getting on my nerves for some time now.

I have been trying to make a simple script for registering a user via MySQL.No filtering input, no validating only the part that adds the new user into the MySQL table. But it doesn't work.I have checked my code a couple of times and i can't see the problem.Here it is:
  1. <?php
  2. if(isset($_POST["name"]) && isset($_POST["pass"]) && isset($_POST["email"]))
  3. {
  4. $name=$_POST["name"];
  5. $pass=$_POST["pass"];
  6. $email=$_POST["email"];
  7. $con=mysql_connect('localhost','root','password');
  8. if (!$con)
  9. {
  10. die('Could not connect: ' . mysql_error());
  11. }
  12. mysql_select_db("users", $con);
  13. mysql_query("INSERT INTO members (username,password,email) values ('$name','$pass','$email')") or die('Error');
  14. }
  15. ?>

Hi,
You have get name,pass,email in a html form using a submit button and then later you have to post the details using $post

See the form given below

  1. <form name="form1" method="post" action="">
  2. Name
  3. <input type="text" name="Name" value="">
  4. Pass
  5. <input type="password" name="Pass" value="">
  6. Email
  7. <input type="text" name="Email" value="">
  8. <input type="submit" name="Submit" value="Submit">
  9. </form>
  10. <?
  11. if(isset($_POST['Submit'']))
  12. {
  13. $name=$_POST['Name'];
  14. $pass=$_POST['Pass'];
  15. $email=$_POST['Email'];
  16. $con=mysql_connect('localhost','root','password');
  17. if (!$con)
  18. {
  19. die('Could not connect: ' . mysql_error());
  20. }
  21. mysql_select_db("users", $con);
  22. mysql_query("INSERT INTO members (username,password,email) values ('$name','$pass','$email')") or die('Error');
  23. }
  24.  

I think it should be work!
Last edited by peter_budo; Dec 23rd, 2008 at 6:56 pm. Reason: Adding code tag
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 2706 | Replies: 35
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC