I want to ask a question in php
this is html form code
<form id="BlahForm" name="BlahForm" method="post" action="page1.php">
<input type="radio" name="rdPS" value="RJ"/> Space 1
<input type="radio" name="rdPS" value="SM" />Space 2
<input type="submit" name="submit" value="Submit">
</form>
This is PHP code
if(isset($_POST['submit'])) // Check this line. Here I have Q-1
{
if(isset($_POST['rdPS'])) // Check this line. Here I have Q-2 & Q-3
{
$choice_port = $_POST["rdPS"];
}
else // Check this line. Here I have Q-4
{
$message = "Radio button not clicked";
}
}
Now read questions in the format they are asked..
Q-1. what does first isset does? if(isset($_POST[‘submit’]))
(WHAT I KNOW IS ISSET CHECKS WHETHER SUBMIT BUTTON IS CLICKED OR NOT?)
Q-2. what does 2nd isset does?
(WHAT I WAS THINKING THAT THIS 2ND ISSET CHECKS WHETHER OR NOT RADIO BUTTON IS CLICKED.
Q-3 Is 2nd isset necessary?
Q-4 This else does not works.. Why??
Thanks is advance for your help..
isset($_POST['submit'])checks is the form is being submitted.isset($_POST['rdPS'])checks if the radio button is selected.elsedoesn’t work because you keep clicking on the radio button.You should look into some tutorials on PHP. Pretty basic stuff.