FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


help me please with my problem





glena
i made an online voting using sms..

i stored all the infos including date, message and sender into mysql database..

lets say if you want to vote you will write VOTE+space+name - this info will be save to message in mysql database


problem is how can i check that he has write VOTE and the name? how can i extract the word VOTE and name from message??

please help me..
Diablosblizz
You can get what was typed into the field with:

Code:
$name = $_POST['INPUTNAMEHERE'];
if($name == "whatever") {
echo "whatever";
} else {
echo "Whatever2";
}
rvec
or if you want to select all rows starting with 'VOTE' from a mysql database:
Code:
SELECT * FROM table WHERE message LIKE VOTE%


and if you want to get the name part only:
Code:
<?php
$sms = "VOTE test"//just an example sms
$array= explode(" ", $sms); //make an array of the string
$name = $array[1];//store the second value in $name
?>
themit
If they are using space, or a similar character, you can use the explode function to make an array out of a string.

Example:

I SMS: Yes 0419192192 Paul Smythe

Use the code:
Code:

$string="Yes 0419192192 Paul Smythe";
$data= explode(" ", $string);
if(isset($data[0]))
echo 'Thanks for including your vote!';
if(isset($data[1]))
echo 'Thanks for including your number!';
if(isset($data[2]))
echo 'Thanks for including your first name!';
if(isset($data[3]))
echo 'Thanks for including your last name!';
if(isset($data[4]))
echo 'You have put in too many spaces or extra data that is not needed.';

Obviously you need to validate each item and so fourth, but now you have the items, it is quite easy to do from there.

Be careful that people don't put in incorrect spaces.

An entry like: Yes 0419192192 must be properly validated and be filtered out to avoid crashing the system.
rvec
I did use explode Wink
themit
I know, I just helped out a bit by explaining it further. I had no idea what explode did when I first saw it used.
glena
yeeess!! thanks to all of you... now my sms project is now finish.. thanks!
Related topics
Strange Fire fox problem
Admins help please, My domain wont work! (its my domain.)
Major Problem with COmputer. Help Please
Please Help Packet Problem
My page dosn't work in IE, is the problem, help please
Help please,"Forbidden You don't have permission to acc
PHP Help please
Iframe issues - Need help please.
I am having alot of trouble with forms! Urgent help please!
I need some help please!
Please help with translations (credits are given)
PLEASE HELP!!.......PLEASE
help please
Help please! I can't login to my blog admin panel
Hmmmm, Favicon not working, check it out and help please
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.