+ 1
Php input field validations ?
I created a form and linked it to the database using php ... In the form i created 3 inputfields ... And i wrote code if the input field is empty and when i click submit it will show the msg that you must enter the value ...if i enter something in one field and i click submit it is clearing the inputfield where i entered the data ...what should i need to do to keep the entered data and remaining inputfields to show their error message
6 Answers
+ 2
@toni it's not working đ
+ 1
@toni i made it as ... if (isset($_POST['name']){
$name = $_POST['name'];
}
and
<input type="text" name ="name" value = "<?php
echo $name ;
?>" >
it worked .... Thank You So much đđ
0
basically u have to store those data in session for a moment
0
Do you get an error if you submit the form and the name input is empty? If so declare empty $name variable outside your if statement
- 1
make empty public variables for your inputs
$name = ââ;
make if statement (click function) for your submit button
if($_POST[âbuttonâ]) {
//if inputs are not empty store the value into the correct variable
$name = $_POST[ânameâ];
}
Put the php variable into your input value
<input type=âtextâ name=ânameâ value=â<?php echo $name; ?>â />
- 1
@Tarak it should