Reputation: 1449
<div>
<h2>How many services do you need ?</h2>
<form action="<?php $_SERVER['PHP_SELF']?>" method="GET" name="fServ">
<input type="number" name="numServ" />
<input type="submit" value="SEND">
</form>
<div>
<?php
if(isset($_GET['numServ'])){
echo "We need ".$_GET['numServ']." services";
}
if(!isset($_GET['numServ'])){
echo "We don't have any services yet.";
}
else if($_GET['numServ']=""){
echo "Please put in a number";
}
Say you have this following form, it works if I put in a number or access the form on first load. However I could never on the last if statement : ( Put in a number )
I have tried with POST and GET methods. GET methods will show : .php?numServ=
I tried :
if((isset($_POST['numServ']) && $_POST['numServ']=="")
if(empty($_POST['numServ']))
if(is_null($_POST['numServ']))
if($_POST['numServ'] == "")
if($_POST['numServ'] == null)
I stil can't fall in the last condition.
Upvotes: 0
Views: 105
Reputation: 6950
one thing I can see in code
if($_GET['numServ']="")
You are using assignment operator here Please replace it with
if($_GET['numServ']=="")
and you should be fine with get method
Upvotes: 1