+ 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 Respuestas
+ 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