0
INPUT VALUE TO USE IN IF STATEMENTS IN PHP
How can I use the value received from the user by input box in if . For example :I received a user input of "Alex" Now I want to use the Alex in if statement so that the if statement will only execute or echo it is true when the user input is <?php $value = $_POST["user"]; If($value==Alex){ Echo ("yes"); } Else { Echo("no"); } So is it right ,whenever I run this ok local host it show error of Alex value Can anyone help me with this I'm a beginner.
3 Respostas
+ 2
// Write if($value == "Alex")
Because Alex is string so we have to write it between " " or '.' ;
Or
//$username ="Alex" ;
if($value == $username)
Here we already put a value to $username with "Alex"
+ 1
Whenever you're working with a string in an if statement you should put it inside quotation marks.
0
Change the if statement to this:
if($value=="Alex")