I cannot insert database

  • Answered
success submit the form but database column data is empty. "") { ++$studentID; } else { $studentID = "001"; } extract($_POST); $insertSQL = mysql_query("INSERT INTO student(sName, sID, sPass, sProgram, sBatch, sEmail, sContact1, sContact2, sIC, sGender, sDateOfBirth, sNational, sAddress) VALUES ('$sName','$sID','$sPass','$sProgram','$sBatch','$sEmail','$sContact1','$sContact2','$sIC','$sGender','$sDateOfBirth','$sNational','$sAddress')"); if ($insertSQL) { echo '' , 'window.alert("Register Add Successful");' , 'location.replace("studentRegister.php");' , ''; } else{ echo "alert('Submit Fail')"; } } ?>
Hello, Thank you for your question about form data in your database. It looks like the `mysql_query()` function was deprecated in some versions in PHP and outright removed in version 7. I advise checking your PHP Configuration for version information. It is recommended by the PHP Documentation that you switch to the MySQLi extension. Otherwise, you would need to try your code in an older version of PHP. However, it is well advise to update your code to match new versions rather than downgrade or use older software. Best, Christopher M.