Help creating hidden variable to send sms form confirmation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kr38t1v1t33
Forum Newbie
Posts: 4
Joined: Fri Feb 25, 2011 11:33 am

Help creating hidden variable to send sms form confirmation

Post by kr38t1v1t33 »

Hi there,

I need help to try to produce a php form that will take the value from the filled form field called ... mobile and on submission of the form that value is placed inside of a mailto:{mobile}@email2smsserver.com?subject=Your Form Data has been recieved , this can then be sent as an sms through an email to sms gateway.

I hope this makes sense, I am not much of a programmer but I will give it a go.

Thanks.
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

Re: Help creating hidden variable to send sms form confirmat

Post by danwguy »

if you are using method post in your form then on your send php page use

Code: Select all

$mobile = $_POST['mobile'];
then just use that $mobile variable however you want.

Do you need help setting up the whole mail submission script? or just needed to know how to pull a value from a form?

EDIT: I wouldn't use mailto: in cases where you want the mail to automatically send, I would use php's built in mail() function instead.
kr38t1v1t33
Forum Newbie
Posts: 4
Joined: Fri Feb 25, 2011 11:33 am

Re: Help creating hidden variable to send sms form confirmat

Post by kr38t1v1t33 »

Thanks danwguy for your helpful response.

To be honest I would love to see an example code that will do the following:

Dummy Form example;

Name: John Smith
Address: My Street
Mobile: 0412345678
Email: myemail@mydomain.com

I have access to an sms gateway that will either accept authentication via a php script that they provide or via an email to sms method,

To send an SMS on submit via the email to sms method, I need to be able to capture the data in the Moble: field and then be able to place that data in this format - mobile_number@smsgateway.com in the form submit process so the form can send an sms and an email confirmation message.

The message for the sms is derived from either the subject of the email or the body of the email and because we are limited to 160 chars for the sms message I would need to tell the script to send a different subject or body message to the sms gateway and the full confirmation data to an email address...I hope this makes sense to you :)

They provided me with a sample php script that is only for sending data to the sms gateway but not both sms and email.

Here is the code sample from their PHPscript -

Code: Select all

<?php
require ("SmsInterface.inc");
echo "<P> Message sent to <B>" . $_POST["phone"] . "</B> ";
$si = new SmsInterface (false, false);
$si->addMessage ($_POST["phone"], $_POST["message"]);
if (!$si->connect ($_POST["username"], $_POST["password"], true,
false))
echo "failed. Could not contact server.\n";
elseif (!$si->sendMessages ()) {
echo "failed. Could not send message to server.\n";
if ($si->getResponseMessage () !== NULL)
echo "<BR>Reason: " . $si->getResponseMessage () . "\n";
} else
echo "OK.\n";
?>
So, what do you think is the best solution? email to sms or modify the php script somehow and use that method?

Thanks again for your advice.
kr38t1v1t33
Forum Newbie
Posts: 4
Joined: Fri Feb 25, 2011 11:33 am

Re: Help creating hidden variable to send sms form confirmat

Post by kr38t1v1t33 »

Does anyone have a sample script for something like this?

Cheers.
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

Re: Help creating hidden variable to send sms form confirmat

Post by danwguy »

I would say email to sms would be easier, store all the variables from the form in your own php script, then use php's mail() function to send it off. Post up the code for the form that they fill out to do the email to sms
kr38t1v1t33
Forum Newbie
Posts: 4
Joined: Fri Feb 25, 2011 11:33 am

Re: Help creating hidden variable to send sms form confirmat

Post by kr38t1v1t33 »

Thanks danwguy...

Would you be kind enough to post an example of the process and how the script would be written?

Thanks.
Post Reply