Jump to content

sms script coding help


efuzone

Recommended Posts

Hello,

 

I have made my own SMS Server and setup there Remote Mysql,

 

Software download messages from database and then send from mobile device.

 

I have made one simple html form + php submit page with database info but the submit page is not sending text to database can you please check where i am wrong?

 

HTML FORM CODE:

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Send Free SMS</title>
</head>

<body>

<Strong>Send Free SMS to Any Mobile Network in Pakistan</strong><br />
<script language = "Javascript">
maxL=255;
var bName = navigator.appName;
function taLimit(taObj) {
if (taObj.value.length==maxL) return false;
return true;
}
function taCount(taObj,Cnt) { 
objCnt=createObject(Cnt);
objVal=taObj.value;
if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
if (objCnt) {
	if(bName == "Netscape"){	
		objCnt.textContent=maxL-objVal.length;}
	else{objCnt.innerText=maxL-objVal.length;}
}
return true;
}
function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval("document." + objId);
else if (document.all) return eval("document.all." + objId);
else return eval("document." + objId);
}
</script>
<form name="sendsms"" action="submit.php" method="POST">
<table border="0" width="525" height="234"><tr><td width="130" valign="bottom"><font size="2" face="Arial">    </font>
<font face="Arial" style="font-size: 9pt"><b>  Mobile Number:</b></font></td>
<td width="410" valign="bottom"><select name="mobnet">
<option value="300">0300</option>
<option value="301">0301</option>
<option value="302">0302</option>
<option value="303">0303</option>
<option value="304">0304</option>
<option value="305">0305</option>
<option value="306">0306</option>
<option value="307">0307</option>
<option value="308">0308</option>
<option value="312">0312</option>
<option value="313">0313</option>
<option value="314">0314</option>
<option value="315">0315</option>
<option value="321">0321</option>
<option value="322">0322</option>
<option value="323">0323</option>
<option value="331">0331</option>
<option value="332">0332</option>
<option value="333">0333</option>
<option value="334">0334</option>
<option value="335">0335</option>
<option value="336">0336</option>
<option value="342">0342</option>
<option value="343">0343</option>
<option value="344">0344</option>
<option value="345">0345</option>
<option value="346">0346</option>
<option value="347">0347</option>
<option value="355">0355</option>
<option value="364">0364</option>
</select><input type="text" name="phone" size="20" maxlength="7" /><font face="Arial" style="font-size: 7pt"><font color="#FF0000">*</font>Must Be 7 Digits e.g. 1234567</font></td></tr><tr><td width="130" height="24"><font size="2" face="Arial"></font><font face="Arial" style="font-size: 9pt"><b>  Sender Name:</b></font></td><td width="410" height="24"><input type="text" name="sender" size="28"><font face="Arial" style="font-size: 7pt"><font color="#FF0000">*</font>Must Be Your Real Name/Phone Number</font></td></tr><tr><td valign="top" width="130" height="118"><font size="2" face="Arial"></font><font face="Arial" style="font-size: 9pt; font-weight: 700">  Text Message:</font></td><td width="410" height="118"><textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="text" wrap="physical" cols="43" rows="7"></textarea></tr><tr align=center><td><br /></td><td><br /></td></tr><br><br>You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining
<tr><td colspan="2" align="center" height="29"><p><font size="2" face="Arial"><strong>By Submitting This Form You agreed to our "<a href="#">Term of Use</a>"</Strong></font></p><br><input type="submit" name="sendsms" value="Send" onSubmit="stripHTML(this.text)"></td></tr></table></form>
</body>

</html>

 

 

PHP CODE:

<?php

function SendSMS()
{
$mytext = $_REQUEST['text'];
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);

$void_text = array("zardari", "harami", "chod", "lun", "lund", "phuddi", "puddi", "bastered", "fuck", "janab asif zardari", "behn chod", "teri behn ki", "teri man ki", "fucking", "fucked", "choot", "gand", "gandu");
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
	for ($j=0; $j<$count_explode; $j++)
	{
		if ($text_explode[$j]==$void_text[$i])
		$words = "$words, $text_explode[$j]";
	}
}
if (!empty($words)) {
		$error .= 'You have entered valgur or suspecious words'. $words.'\n';
	}


if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<7) { 
$error .= 'Enter Valid Phone Number \n';
}
if (empty($_REQUEST['sender']) or strlen($_REQUEST['sender'])<4) { 
$error .= 'Enter Your Correct Name\n';
}

@$db = mysql_connect("localhost", "smszone_messages" , "smszone_mysms", "M..1234");
if (!$db) { 
$error .= 'Error connecting to Database\n';

}
if (!empty($error)) { ?>
<script language="javascript">alert( '<?php echo $error ?>' )</script>
<?php
}
else {
mysql_select_db("Messages");
$direction = "2";
$statusdetails = "201";
$type = "2";
$status = "1";
$channelID = "1001";
$FromAddress = $_REQUEST['from'];
$ToAddress = "+92".$_REQUEST['mobnet'].$_REQUEST['phone'];

        $body = $_REQUEST['sender'].' Says: \n'.strip_tags($_REQUEST['text']).'\n visit http://www.smszone.pk/test';

$query = "INSERT INTO messages (Direction, Type, StatusDetails, Status, ChannelID, Sender, Recipient, Body)
		 VALUES ('$direction', '$type', '$statusdetails', '$status', '$channelID', '$FromAddress', '$ToAddress', '$body')";
$result = mysql_query($query);
if (!$result) { ?>
<script language="javascript" >alert("Error Connecting with SMS Server")</script>	
<?php
}
}

return $result;
mysql_close();

     }
?>

 

DB TABLE NAME "Messages":

 

ID	 	 	 	 	 	 	
Direction
Type	
StatusDetails
Status
ChannelID
MessageReference
SentTimeSecs
ReceivedTimeSecs
ScheduledTimeSecs
LastUpdateSecs
Sender
Recipient
Subject
BodyFormat
CustomField1
CustomField2
sysCreator
sysArchive
sysLock
sysHash
sysForwarded
sysGwReference
Header
Body
Trace		 	 	 				 

 

 

Please help

Link to comment
Share on other sites

hey efuzone...

 

Let me ask something... in your form submit button you have

onSubmit="stripHTML(this.text)"

First of all, what is the purpose of that function and what exactly should it do?

and second i can't find the stripHTML function in your code. Do you get that function from including a javascript file? if not i think that's the problem.

Link to comment
Share on other sites

ok it seems that in your submit.php file you have the complete code into a function but you never call that function so you either remove the function property so it becomes like :

 

submit.php

$mytext = $_REQUEST['text'];
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);

$void_text = array("zardari", "harami", "chod", "lun", "lund", "phuddi", "puddi", "bastered", "fuck", "janab asif zardari", "behn chod", "teri behn ki", "teri man ki", "fucking", "fucked", "choot", "gand", "gandu");
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
	for ($j=0; $j<$count_explode; $j++)
	{
		if ($text_explode[$j]==$void_text[$i])
		$words = "$words, $text_explode[$j]";
	}
}
if (!empty($words)) {
		$error .= 'You have entered valgur or suspecious words'. $words.'\n';
	}


if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<7) { 
$error .= 'Enter Valid Phone Number \n';
}
if (empty($_REQUEST['sender']) or strlen($_REQUEST['sender'])<4) { 
$error .= 'Enter Your Correct Name\n';
}

@$db = mysql_connect("localhost", "smszone_messages" , "smszone_mysms", "M..1234");
if (!$db) { 
$error .= 'Error connecting to Database\n';

}
if (!empty($error)) { ?>
<script language="javascript">alert( '<?php echo $error ?>' )</script>
<?php
}
else {
mysql_select_db("Messages");
$direction = "2";
$statusdetails = "201";
$type = "2";
$status = "1";
$channelID = "1001";
$FromAddress = $_REQUEST['from'];
$ToAddress = "+92".$_REQUEST['mobnet'].$_REQUEST['phone'];

        $body = $_REQUEST['sender'].' Says: \n'.strip_tags($_REQUEST['text']).'\n visit http://www.smszone.pk/test';

$query = "INSERT INTO messages (Direction, Type, StatusDetails, Status, ChannelID, Sender, Recipient, Body)
		 VALUES ('$direction', '$type', '$statusdetails', '$status', '$channelID', '$FromAddress', '$ToAddress', '$body')";
$result = mysql_query($query);
if (!$result) { ?>
<script language="javascript" >alert("Error Connecting with SMS Server")</script>	
<?php
}
}

return $result;
mysql_close();

or at the bottom of your php file right before the php closing tag "?>" put this

SendSMS();

Link to comment
Share on other sites

OK do you have the appropriate

$conn=mysql_connect('location','username','password');


if (!$conn = mysql_connect('location', 'username', 'password') ) {
	die(mysql_error());
}

//Select the database

if (!mysql_select_db('database',$conn) ) {
	die('Could not select database');

}

functions in your php code?

Link to comment
Share on other sites

noo i have only written

 

	@$db = mysql_connect("localhost", "smszone_messages" , "smszone_mysms", "M..1234");

 

and you can see submit.php there is no lines like this

 

my host is localhost

database username is smszone_mysms

database name is smszone_messages

and pass is M..1234

Link to comment
Share on other sites

change the following lines like:

mysql_select_db("Messages");
//to this
mysql_select_db("smszone_messages");

// and this 
@$db = mysql_connect("localhost", "smszone_messages" , "smszone_mysms", "M..1234");
//to this
@$db = mysql_connect("localhost", "smszone_mysms", "M..1234");

Link to comment
Share on other sites

hmmm see my complete coding can you write it wth all database commands?

 

I copy as it is and then check actully i am basic student in PHP

 

Code:

<?php

$mytext = $_REQUEST['text'];
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);
$void_text = array("zardari", "harami", "chod", "lun", "lund", "phuddi", "puddi", "bastered", "fuck", "janab asif zardari", "behn chod", "teri behn ki", "teri man ki", "fucking", "fucked", "choot", "gand", "gandu");
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
for ($j=0; $j<$count_explode; $j++)
{
if ($text_explode[$j]==$void_text[$i])
$words = "$words, $text_explode[$j]";	
}
}	
if (!empty($words)) {	
$error .= 'You have entered valgur or suspecious words'. $words.'\n';
}
if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<7) { 	
$error .= 'Enter Valid Phone Number \n';
}
if (empty($_REQUEST['sender']) or strlen($_REQUEST['sender'])<4) { 
$error .= 'Enter Your Correct Name\n';
}
@$db = mysql_connect("localhost", "smszone_messages", "smszone_mysms", "MySMS..1234");
if (!$db) { $error .= 'Error connecting to Database\n';
}
if (!empty($error)) { ?>
<script language="javascript">alert( '<?php echo $error ?>' )</script>
<?php
}
else {	
mysql_select_db("Messages");
$direction = "2";
$statusdetails = "201";
$type = "2";
$status = "1";
$channelID = "1001";
$FromAddress = $_REQUEST['from'];
$ToAddress = "+92".$_REQUEST['mobnet'].$_REQUEST['phone'];

$body = $_REQUEST['sender'].' Says: \n'.strip_tags($_REQUEST['text']).'\n visit http://www.smszone.pk/test';

$query = "INSERT INTO messages (Direction, Type, StatusDetails, Status, ChannelID, Sender, Recipient, Body)
VALUES ('$direction', '$type', '$statusdetails', '$status', '$channelID', '$FromAddress', '$ToAddress', '$body')";

$result = mysql_query($query);
if (!$result) { ?>

<script language="javascript" >alert("Error Connecting with SMS Server")</script>
<?php
}
}	
return $result;	
mysql_close();
?>

Link to comment
Share on other sites

Try it now

<?php

$mytext = $_REQUEST['text'];
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);
$void_text = array("zardari", "harami", "chod", "lun", "lund", "phuddi", "puddi", "bastered", "fuck", "janab asif zardari", "behn chod", "teri behn ki", "teri man ki", "fucking", "fucked", "choot", "gand", "gandu");
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
for ($j=0; $j<$count_explode; $j++)
{
if ($text_explode[$j]==$void_text[$i])
$words = "$words, $text_explode[$j]";	
}
}	
if (!empty($words)) {	
$error .= 'You have entered valgur or suspecious words'. $words.'\n';
}
if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<7) { 	
$error .= 'Enter Valid Phone Number \n';
}
if (empty($_REQUEST['sender']) or strlen($_REQUEST['sender'])<4) { 
$error .= 'Enter Your Correct Name\n';
}
@$db = mysql_connect("localhost", "smszone_mysms", "MySMS..1234");
if (!$db) { $error .= 'Error connecting to Database\n';
}
if (!empty($error)) { ?>
<script language="javascript">alert( '<?php echo $error ?>' )</script>
<?php
}
else {	
mysql_select_db("smszone_messages",$db);
$direction = "2";
$statusdetails = "201";
$type = "2";
$status = "1";
$channelID = "1001";
$FromAddress = $_REQUEST['from'];
$ToAddress = "+92".$_REQUEST['mobnet'].$_REQUEST['phone'];

$body = $_REQUEST['sender'].' Says: \n'.strip_tags($_REQUEST['text']).'\n visit http://www.smszone.pk/test';

$query = "INSERT INTO messages (Direction, Type, StatusDetails, Status, ChannelID, Sender, Recipient, Body)
VALUES ('$direction', '$type', '$statusdetails', '$status', '$channelID', '$FromAddress', '$ToAddress', '$body')";

$result = mysql_query($query);
if (!$result) { ?>

<script language="javascript" >alert("Error Connecting with SMS Server")</script>
<?php
}
}	
return $result;	
mysql_close();
?>

Link to comment
Share on other sites

now its fine means giving blank page means db working fine but..

 

in my smszone_messages ther is Messages database no data found there...

 

its still emtpy

 

check database looks like:

 

smszone_messages (6)

 

BodyFormats

Directions

Messages

Status

StatusDetails

Type

 

 

and in Messages database there are tables where form data gooo

Link to comment
Share on other sites

ok and the reason that you see nothing on the page is that you dont have a 'success' message.

Try this:

<?php

$mytext = $_REQUEST['text'];
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);
$void_text = array("zardari", "harami", "chod", "lun", "lund", "phuddi", "puddi", "bastered", "fuck", "janab asif zardari", "behn chod", "teri behn ki", "teri man ki", "fucking", "fucked", "choot", "gand", "gandu");
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
for ($j=0; $j<$count_explode; $j++)
{
if ($text_explode[$j]==$void_text[$i])
$words = "$words, $text_explode[$j]";	
}
}	
if (!empty($words)) {	
$error .= 'You have entered valgur or suspecious words'. $words.'\n';
}
if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<7) { 	
$error .= 'Enter Valid Phone Number \n';
}
if (empty($_REQUEST['sender']) or strlen($_REQUEST['sender'])<4) { 
$error .= 'Enter Your Correct Name\n';
}
@$db = mysql_connect("localhost", "smszone_mysms", "MySMS..1234");
if (!$db) { $error .= 'Error connecting to Database\n';
}
if (!empty($error)) { ?>
<script language="javascript">alert( '<?php echo $error ?>' )</script>
<?php
}
else {	
mysql_select_db("smszone_messages",$db);
$direction = "2";
$statusdetails = "201";
$type = "2";
$status = "1";
$channelID = "1001";
$FromAddress = $_REQUEST['from'];
$ToAddress = "+92".$_REQUEST['mobnet'].$_REQUEST['phone'];

$body = $_REQUEST['sender'].' Says: \n'.strip_tags($_REQUEST['text']).'\n visit http://www.smszone.pk/test';

$query = "INSERT INTO messages (Direction, Type, StatusDetails, Status, ChannelID, Sender, Recipient, Body) VALUES ('$direction', '$type', '$statusdetails', '$status', '$channelID', '$FromAddress', '$ToAddress', '$body')";

$result = mysql_query($query);
if (!$result) { ?>

<script language="javascript" >alert("Error Connecting with SMS Server")</script>
<?php
}
else 
{
?>

<script language="javascript" >alert("SMS Sent")</script>
<?php
}
}	

mysql_close();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.