Passing Variables and Echoing them
Posted: Tue Dec 02, 2014 8:50 pm
Hi. I am a novice at PHP but Im learning.
I created a form page that accepts some input and posts some variables to a php page. It is a text messaging api that runs via Twilio which is a MMS service I signed up for. They supplied me with the parameters and the php page which gets called in my post page. My form is..
sendit.php looks like...
This is working and it sends a text message to the number in $myto ... but Im not sure if it is proper coding technique to use the $_POST["mymessage"] again down there. I originally tried ...
but that resulted in an echo that looked like this: Sent Array to Array.
So my first question is - Why cant I use my variables in an echo?
My 2nd question which will just make my life easier is: How can I send the phone number I would like to send the text message to the form (<input type="text" name="phone" value="">) from a link in an email so that it automatically gets filled in?
Thanks!
I created a form page that accepts some input and posts some variables to a php page. It is a text messaging api that runs via Twilio which is a MMS service I signed up for. They supplied me with the parameters and the php page which gets called in my post page. My form is..
Code: Select all
<form action="sendit.php" method="post" name="form1">
<table>
<tr>
<td align="right">Phone:</td>
<td><input type="text" name="phone" value=""></td>
</tr>
<tr>
<td align="right">Your Message:</td>
<td><input type="text" name="mymessage" value=""></td>
</tr>
<tr>
<td align="right"><input type="submit" value="Submit" name="submit"></td>
</tr>
</table>
</form>Code: Select all
<?php
// this line loads the library
require('Services/Twilio.php');
$account_sid = 'xxxxx';
$auth_token = 'xxxxx';
$client = new Services_Twilio($account_sid, $auth_token);
$myto["phone"] = $_POST["phone"];
$mybody["mymessage"] = $_POST["mymessage"];
;
$client->account->messages->create(array(
'To' => $myto,
'From' => "+19145551212",
'Body' => $mybody,
));
echo 'Sent ' .$_POST["mymessage"]. ' to '.$_POST["phone"];Code: Select all
echo 'Sent ' .$mybody. ' to '.$myto;So my first question is - Why cant I use my variables in an echo?
My 2nd question which will just make my life easier is: How can I send the phone number I would like to send the text message to the form (<input type="text" name="phone" value="">) from a link in an email so that it automatically gets filled in?
Thanks!