wesmanbigmig13
asked on
HTML Form with URL post and variables
I need to set up a simple HTML form that contains 5 text fields on it: USERNAME, PASSWORD, PHONE NUMBER, FROM NAME and SAMPLE TEXT.
When the user has completed the 5 fields and clicks the submit button on the form, it should run the following PHP code/script, passing the 5 variables to it:
How do I do this?
Thanks
When the user has completed the 5 fields and clicks the submit button on the form, it should run the following PHP code/script, passing the 5 variables to it:
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$destination = 'PHONE NUMBER';
$source = 'FROM NAME';
$text = 'SAMPLE TEXT';
$content = 'action=sendsms'.
'&user='.rawurlencode($username).
'&password='.rawurlencode($password).
'&to='.rawurlencode($destination).
'&from='.rawurlencode($source).
'&text='.rawurlencode($text);
$smsglobal_response = file_get_contents('http://www.smsglobal.com.au/http-api.php?'.$content);
//Sample Response
//OK: 0; Sent queued message ID: 04b4a8d4a5a02176 SMSGlobalMsgID:6613115713715266
$explode_response = explode('SMSGlobalMsgID:', $smsglobal_response);
if(count($explode_response) == 2) { //Message Success
$smsglobal_message_id = $explode_response[1];
//SMSGlobal Message ID
echo $smsglobal_message_id;
} else { //Message Failed
echo 'Message Failed'.'<br />';
//SMSGlobal Response
echo $smsglobal_response;
}
?>
How do I do this?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Ray - that code looks great, however when we run it as a PHP page it simply says Message Failed when we submit the form. We have double-checked that we are using the correct variable names and the correct values for the variables, but it just will not send the message to the SMSGlobal gateway. It simply errors with the message: "Message Failed"
Is there possibly something out of line in the code you have supplied?
Thanks
Is there possibly something out of line in the code you have supplied?
Thanks
I don't know -- I cannot test it because I do not have the credentials to test it. If you want to try it on my server, the link is here. Please let me know what you find!
http://www.laprbass.com/RAY_temp_wesmanbigwig13.php
Thanks and regards, ~Ray
http://www.laprbass.com/RAY_temp_wesmanbigwig13.php
Thanks and regards, ~Ray
ASKER
Thanks Experts - I couldn't get it working successfully using the code supplied, but Ray's method was best.
Please take a quick look at the grading guidelines. When you're giving us incomplete information (eg: we cannot test because the resource you want to acquire is behind a password-protected wall) it's nearly impossible to give you a complete answer. In these cases the best approach is to set up a test account so you can give out the credentials and get help from those of us who can test and show you the answer. Giving a marked-down grade is not the right way to get additional help.
http://support.experts-exchange.com/customer/portal/articles/481419
http://support.experts-exchange.com/customer/portal/articles/481419
ASKER
Thanks Ray, but in this case it isn't possible to give out test credentials because the only credentials we have are our own account details. I did award you the lion's share of the points for your help but after spending 2 hours trying to get the code you supplied to work and still not being able to get it to work we had to seek out an alternate solution that did work. Thanks
ASKER