Php required field -
i trying insert records dont know how check required fields , form controls.can show me how can check required fields? new in php. thank you.
if(isset($_post['submitted']) == 1) { $ad = mysqli_real_escape_string($dbc, $_post['name']); $soyad = mysqli_real_escape_string($dbc, $_post['surname']); $email = mysqli_real_escape_string($dbc, $_post['email']); $q = "insert db (name, surname,email) values ('$name', '$surname', '$email')"; $r = mysqli_query($dbc, $q); if($r){ $message = '<p>message added!</p>'; } else { $message = '<p>could not add because: '.mysqli_errno($dbc); $message .= '<p>'.$q.'<p>'; } }
your form , php code not aware of limitation set on database table. can ask database how table looks using describe keyword followed table name. (http://dev.mysql.com/doc/refman/5.7/en/describe.html). response tell if field's allowed null or not. based on can create form take consideration.