Hello all. I am new to PHP programming and am working on my first project. It's a very simple page that allows the user to send a message via text or email to other users. Unfortunately, I have hit a snag early on and have been unable to overcome it.
I am trying to allow the user to select either text or email (via radio input). When this is done, the page is to present a text box with either a 185 or 500 character limit, depending on the selection. This is my code so far:
<HTML>
<HEAD>
<TITLE>SMS System</TITLE>
</HEAD>
<BODY>
<form method = "post">
How will you be sending your message?<br />
<input type = 'radio' name = 'method' value = 'text' checked = 'yes' /> Text to mobile
<input type = 'radio' name = 'method' value = 'email' /> Email
<br />
<br />
<br />
<?php
$selected_radio = $_POST['method'];
if($selected_radio == 'text'){
echo "Enter your message below:";
echo "<input type = 'text' id = 'message' name = 'message' maxlength = '185' />";
}
?>
</form>
</BODY>
</HTML>
I get an error on the line " $selected_radio = $_POST['method'];" that says "Undefined index: method". However, I clearly defined method as the radio selection. I have tried multiple ways to fix this issue: switching between double quotes and single quotes, using GET instead of POST, separating the code into a PHP file and an HTML file, and changing the name of "method" to something else. None of this has worked.
I have read up on several websites, and they all accomplish what I am trying to do using the same technique I am using. If anyone here could be of assistance, I would be most appreciative. Thanks so much!