| | |
A little problem with a script
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
can any buddy help me!!!
this is my php sms sending script but i cant send it.
for sending sms any setting reqire?
this is my php sms sending script but i cant send it.
for sending sms any setting reqire?
php Syntax (Toggle Plain Text)
<!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>
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.
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
can any buddy help me!!!
this is my php sms sending script but i cant send it.
for sending sms any setting reqire?
this is my php sms sending script but i cant send it.
for sending sms any setting reqire?
•
•
•
•
<!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>
•
•
Join Date: Dec 2008
Posts: 19
Reputation:
Solved Threads: 1
•
•
•
•
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:
PHP Syntax (Toggle Plain Text)
<?php if(isset($_POST["name"]) && isset($_POST["pass"]) && isset($_POST["email"])) { $name=$_POST["name"]; $pass=$_POST["pass"]; $email=$_POST["email"]; $con=mysql_connect('localhost','root','password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("users", $con); mysql_query("INSERT INTO members (username,password,email) values ('$name','$pass','$email')") or die('Error'); } ?>
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
PHP Syntax (Toggle Plain Text)
<form name="form1" method="post" action=""> Name <input type="text" name="Name" value=""> Pass <input type="password" name="Pass" value=""> <input type="text" name="Email" value=""> <input type="submit" name="Submit" value="Submit"> </form> <? if(isset($_POST['Submit''])) { $name=$_POST['Name']; $pass=$_POST['Pass']; $email=$_POST['Email']; $con=mysql_connect('localhost','root','password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("users", $con); mysql_query("INSERT INTO members (username,password,email) values ('$name','$pass','$email')") or die('Error'); }
I think it should be work!
Last edited by peter_budo; Dec 23rd, 2008 at 6:56 pm. Reason: Adding code tag
![]() |
Similar Threads
- Learning PHP but problem with script (PHP)
- [Bash] problem with script in sed command (Shell Scripting)
- Minor problem with some script... (C)
- Large Array Problem (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP sort control
- Next Thread: Ajax Problem
Views: 2707 | Replies: 35
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





thanks again. 