Jump to content

SMS Message Help


tebrown

Recommended Posts

Hey Guys,

 

I have followed a tutorial and got a SMS text message script working. Although what i would like to do now is allow a registered user to add another user via a form. This form will contain the users mobile number, email, who its from,  and a textarea for the message to send to them in the text message.

 

*** It also stores it into a database. But dont worry about that.

 

I have run into a problem, when i type in a mobile number and an email address and then press send. It doesnt seem to store the email address in the $vars echo (message). **It does echo in the email bit but i wont it to show in the message bit. **

 

Here is a screenshot.

 

 

 

post-132578-13482403398254_thumb.png

Link to comment
Share on other sites

Sorry forgot about the code, here it is:

 

<?php
include"databasesms.php";
?>



<form action="sms.php" method="POST">

Number:<br />
<input type="text" name="number" value="64274144422"/>

<br /><br />

Email:<br />
<input type="text" name="email" value="t.e.brown@hotmail.com"/>

<br /><br />

Password:<br />
<input type="password" name="passcode" />

<br /><br />

From:<br />
<input type="text" name="from" />

<br /><br />

Message:<br />
<textarea name="message"><?php if (isset($_POST['email'])) { print ' ' . $_POST['email'] . ''; } ?></textarea>

<br /><br />

<input type="submit" name="submit" value="Send">

</form>

<?php

$username = "t.e.brown@hotmail.com";
$password = "*******";

if (isset($_POST['submit'])) {

$number = $_POST['number'];
    $number_array = explode(',', $number);
	foreach($number_array as $index => $word) 
	   $number_array[$index] = trim($word);

$message = $_POST['message'];
$email = trim($_POST['email']);
$passcode = $_POST['passcode'];
$from = $_POST['from'];

$vars = "uname=".$username."&pword=".$password."&message=".$message."&email=".$email."&from=".$from."&selectednums=".$number."&info=1&test=1";

echo $vars;




$register = mysql_query("INSERT INTO players (email, password, mobile) VALUES ('".$email."', '".$passcode."', '".$number."')");

{



$curl = curl_init('http://txtlocal.com/sendsmspost.php');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $vars);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);

die("<br /><br />SMS has been sent.");


}
}
?>

Link to comment
Share on other sites

If you hit submit twice, it shows up. You arent filling that area with any value or string until you hit submit the first time. So it shows up empty the first time but leave &message= blank because it was empty before the first submit. On the second submit, there is a value to place into the &message= and it shows up.

 

So you need to fill the area on the first submit. Would doing something like this work for you?

 

$vars = "uname=".$username."&pword=".$password."&message="$email."".$message."&email=".$email."&from=".$from."&selectednums=".$number."&info=1&test=1";

 

Let me know if that works for you! (Im new-ish to PHP so doing my best) let me know

 

glad to help if i did actually help haha

 

algidDes702

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.