eldan88 Posted August 23, 2013 Share Posted August 23, 2013 Hey, I am trying to pass in the $confirmation_method at the end of the /voice.php url, for this voice application API I that I am working on However dreamweaver gives me a syntax error from the line number starting with the variable $call . I think I am not concatenating the code correctly after ?confirmation_method= Any suggestions? Thanks if($_POST['telephone_keypad']) { $confirmation_method = $_POST['telephone_keypad']; //The code below is for the telephone keypad $call = $client->account->calls->create("+17185697116", "+13472734190","http://www.myurl.com/voice_demo/voice.php?confirmation_method=" . echo "{$confirmation_method}",array ("StatusCallback" => "http://www.myurl.com/voice_demo/call_back.php")); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/ Share on other sites More sharing options...
requinix Posted August 23, 2013 Share Posted August 23, 2013 echo is for output only, and it's a statement not an expression (so you can't use it as if it returns a value or something). "http://www.myurl.com/voice_demo/voice.php?confirmation_method={$confirmation_method}"You really should be validating that $confirmation_method before you blindly stick it in a URL like that. Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446494 Share on other sites More sharing options...
eldan88 Posted August 24, 2013 Author Share Posted August 24, 2013 echo is for output only, and it's a statement not an expression (so you can't use it as if it returns a value or something). "http://www.myurl.com/voice_demo/voice.php?confirmation_method={$confirmation_method}"You really should be validating that $confirmation_method before you blindly stick it in a URL like that. Oh okay i see the mistake. What do you mean by validating the $confirmation_method? Aren't i doing that with the if($_POST['telephone_keypad'])? This is how my form looks like Please Select what type confirmation method you would like to use: <?php if(!empty($message)) {echo "<b>" . $message . "</b>";} ?> <form action="confirmation.php" method="post"> Order Management <input type="radio" name="order_management" /><br /> Telephone Keypad <input type="radio" name="telephone_keypad" /><br /> <input type="submit" name="submit" value="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446501 Share on other sites More sharing options...
requinix Posted August 24, 2013 Share Posted August 24, 2013 Just because your form has it as a radio button doesn't mean it will contain the values you expect. Heck, I don't know what value you expect it to have in the first place. If it should even have one. Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446506 Share on other sites More sharing options...
eldan88 Posted August 25, 2013 Author Share Posted August 25, 2013 Just because your form has it as a radio button doesn't mean it will contain the values you expect. Heck, I don't know what value you expect it to have in the first place. If it should even have one. I'm sorry. I'm not to familiar with HTML. What is the use of adding a value in the radio fields? Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446686 Share on other sites More sharing options...
kicken Posted August 25, 2013 Share Posted August 25, 2013 The way you have your form setup right now, a user could select both radio options. It's not an either/or choice which is typically what radio buttons are for. Give it a try for yourself, click the first radio, then the second radio. Both will be selected. The way you are supposed to create radio groups is to give every radio button the same name, but a different value. And, in the odd case you'd actually want the two radios to function separately as they do, you still either need a value or need to change your code to work based on the name. Since the radio's have no value currently, $_POST['telephone_keypad'] would either be an empty string or maybe 'on', not sure how the browsers would treat that. Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446697 Share on other sites More sharing options...
eldan88 Posted August 27, 2013 Author Share Posted August 27, 2013 The way you have your form setup right now, a user could select both radio options. It's not an either/or choice which is typically what radio buttons are for. Give it a try for yourself, click the first radio, then the second radio. Both will be selected. The way you are supposed to create radio groups is to give every radio button the same name, but a different value. And, in the odd case you'd actually want the two radios to function separately as they do, you still either need a value or need to change your code to work based on the name. Since the radio's have no value currently, $_POST['telephone_keypad'] would either be an empty string or maybe 'on', not sure how the browsers would treat that. Wow your are right. I have now added values to it. I know this is an amanuter question, but what conition should I use to validate $confirmation_method? Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446911 Share on other sites More sharing options...
kicken Posted August 27, 2013 Share Posted August 27, 2013 Create a list of valid values and make sure what was submitted is in that list. eg: if (!in_array($_POST['confirmation_method'], ['order_management','telephone_keypad'])){ //invalid submission } Quote Link to comment https://forums.phpfreaks.com/topic/281502-need-help-with-a-_get-request/#findComment-1446914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.