php - HTML form (method = "post") won't submit
Solution:
Good Afternoon, I think its better to use HTML form properties, you want to validate the entered values, so its easy to do it like this: 1- 'Make' should not be empty:
<input type="text" name="make" size="40" required/>
2- 'Year' and 'Mileage' must be numeric:
<input type="number" name="year" size="40"/>
<input type="number" name="mileage" size="40"/>
by this way you dont need to write any php validation for your form, if you want to use php validation let me know to guide you for solving your problem
Answer
Solution:
when Submit button press then first you have to Check Submit Button Post like this:
if(isset($_POST['submit'])){
//Your Code Logic...
}
then get data from POST & store it in variable like this... for Your Reference
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
}
in html...
<body>
<form method="post" action="">
<input type="text" name="username" placeholder="enter username"><br/><br/>
<input type="text" name="password" placeholder="enter password"><br/><br/>
<input type="submit" name="submit" value="submit"/>
</form>
then store in database like this
$sql="insert into user(username, password)
values('$username','$password')";
Source