Jump to content

simbae

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by simbae

  1. requinix#3344 error_reporting(E_ALL); ini_set('display_errors', '1'); i have tried troubleshooting the errors are fewer what needs to be done now <?php ?><?php session_start(); include("connection.php"); include("functions.php"); mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); // Check connection if($con === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } if(isset($_POST['d_name'])){ } if(isset($_POST['manner_death'])){ } if(isset($_POST['place_death'])){ } if(isset($_POST['nok'])){ } if(isset($_POST['rel_nok'])){ } if(isset($_POST['morgue_att'])){ } if(isset($_POST['tag_num'])){ if(isset($_POST['treatment'])) // Escape user inputs for security $d_name = mysqli_real_escape_string($con, $_REQUEST['d_name']); $manner_death = mysqli_real_escape_string($con, $_REQUEST['manner_death']); $place_death = mysqli_real_escape_string($con, $_REQUEST['place_death']); $nok = mysqli_real_escape_string($con, $_REQUEST['nok']); $rel_nok = mysqli_real_escape_string($con, $_REQUEST['rel_nok']); $morgue_att = mysqli_real_escape_string($con, $_REQUEST['morgue_att']); $tag_num = mysqli_real_escape_string($con, $_REQUEST['tag_num']); $treatment = mysqli_real_escape_string($con, $_REQUEST['treatment']); // Attempt insert query execution $query = "insert into data ( d_name, manner_death, place_death ,nok, rel_nok, morgue_att, tag_num, treatment) values ( '$d_name'.'$manner_death','$place_death','$nok','$rel_nok','$morgue_att','$tag_num','$treatment')"; }else if(mysqli_query($con, $query)){ echo "Records added successfully."; } { echo "ERROR: Could not able to execute $query. " . mysqli_error($con); } // Close connection mysqli_close($con); ?>
  2. requinix#3344 what would your code look like, im just a novice kindly highlight my errors
  3. error_reporting(E_ALL); ini_set('display_errors', '1'); <?php session_start(); include("connection.php"); include("functions.php"); // Check connection if($con === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } if(isset($_POST['d_name'])){ if(isset($_POST['manner_death'])){ if(isset($_POST['place_death'])){ if(isset($_POST['nok'])){ if(isset($_POST['rel_nok'])){ if(isset($_POST['morgue_att'])){ if(isset($_POST['tag_num'])){ if(isset($_POST['treatment'])) // Escape user inputs for security $d_name = mysqli_real_escape_string($con, $_REQUEST['d_name']); $manner_death = mysqli_real_escape_string($con, $_REQUEST['manner_death']); $place_death = mysqli_real_escape_string($con, $_REQUEST['place_death']); $nok = mysqli_real_escape_string($con, $_REQUEST['nok']); $rel_nok = mysqli_real_escape_string($con, $_REQUEST['rel_nok']); $morgue_att = mysqli_real_escape_string($con, $_REQUEST['morgue_att']); $tag_num = mysqli_real_escape_string($con, $_REQUEST['tag_num']); $treatment = mysqli_real_escape_string($con, $_REQUEST['treatment']); // Attempt insert query execution $sql = "INSERT INTO data (d_name, manner_death, place_death, nok, rel_nok, morgue_att, tag_num, treatment) VALUES ('$d_name', '$manner_death', ','$place_death','$nok','$rel_nok', '$morgue_att','$tag_num','$treatment')"; }else if(mysqli_query($con, $sql)){ echo "Records added successfully."; } { echo "ERROR: Could not able to execute $sql. " . mysqli_error($con); // Close connection mysqli_close($con); } ?>
  4. anyone who can correct the code for me
  5. <?php session_start(); include("connection.php"); include("functions.php"); if($_SERVER['REQUEST_METHOD'] == "POST") { //something was posted $d_name = $_POST['d_name']; $manner_death = $_POST['manner_death']; $place_death = $_POST['place_death']; $nok = $_POST['nok']; $rel_nok = $_POST['rel_nok']; $morgue_att = $_POST['morgue_att']; $tag_num = $_POST['tag_num']; $treatment = $_POST['treatment']; if(!empty($d_name) && !empty($manner_death) && !is_numeric($user_name)) { //save to database $query = "insert into data (user_id,d_name,manner_death,place_death,nok,rel_nok,morgue_att,tag_num,treatment) values ('$user_id','$user_name','$d_name'.'$manner_death','$place_death','$nok','$rel_nok','$morgue_att','$tag_num','$treatment')"; mysqli_query($con, $query); header("Location: post.php"); die; }else { echo "Please enter some valid information!"; } } ?> <!DOCTYPE html> <html> <head> <title>Post Data</title> </head> <body> <style type="text/css"> #text{ height: 25px; border-radius: 5px; padding: 4px; border: solid thin #aaa; width: 100%; } #button{ padding: 10px; width: 100px; color: white; background-color: lightblue; border: none; } #box{ background-color: #ba33ff; margin: auto; width: 500px; padding: 20px; } </style> <div id="box"> <form method="post"> <div style="font-size: 20px;margin: 10px;color: white;">Enter data</div> Deceased name<input id="text" type="text" name="d_name"><br><br> Manner of death<input id="text" type="text" name="manner_death"><br><br> Place of death<input id="text" type="text" name="place_death"><br><br> Next of kin<input id="text" type="text" name="nok"><br><br> Relationship to Deceased<input id="text" type="text" name="rel_nok"><br><br> Morgue attendant<input id="text" type="text" name="morgue_att"><br><br> Tag name<input id="text" type="text" name="tag_num"><br><br> Treatment<input id="text" type="text" name="treatment"><br><br> <input type="submit" value="Submit"><br><br> </form> <a href="logout.php">Logout</a> </div> </body> </html>
  6. how do i search my database tables using a data submitted from a text box
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.