How to use the if else statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How to use the if else statement

I made a contact form and am wondering how i can make a mesage to say that youve not entered your first name please do so

27th Sep 2016, 12:31 AM
Festus M
Festus M - avatar
2 Answers
0
You can use attribute required in input tag: <input name="user" required> or use php: if(empty($_POST['user']) { echo 'user field is required!'; }
27th Sep 2016, 1:25 PM
Dmitri Daranuta
Dmitri Daranuta - avatar
0
you can solve this problem with this code : HTML : <Input type="text" name="txt1"/> <input type="submit" value="get"/> And you must save that code in a .php file in body tag and you must type under code outside of HTML tag : <?php if(isset($_POST(['txt1'])){ echo 'Ok you typed your name'; }else{ echo 'Ohh , you must type your name'; }
16th Dec 2016, 3:15 PM
Ahmad Yazdani
Ahmad Yazdani - avatar