php - Duplicating data in SQL -
i making database validation system. upon validation, handler supposed send data email address, while simultaneously updating data database. values of id, name, board, query , rand received previous page. now, given code, unable update table named 'answers' within database. line of code functionality in bold.
<?php $servername = "localhost"; $username = "root"; $password = ''; $dbname = "bsp"; $conn1 = new mysqli($servername, $username, $password, $dbname); $id=""; $value = ""; $name = ""; $board = ""; $query=""; $id = $_post['id']; $name = $_post['name']; $board = $_post['board']; $query = $_post['query']; $rand = $_post['rand']; $value=$_post['option']; $to=""; $subject=""; $msg=""; $headers=""; if($value=='delete') { $sql="delete rti id=$id"; if ($conn1->query($sql) === true) { echo "record deleted successfully"; } else { echo "error deleting record: " . $conn1->error; } } else if($value=='validate') { **$sql="insert answers (name, board, query, rand) values (\"$name\", \"$board\", \"$query\", \"$rand\")";** if($board=='brca') { $to = 'email@gmail.com'; $subject = 'rti query: not reply email.'; $msg = "your code " . $rand . "."; $msg .= " visit localhost/bsp/landing.php , post code, , subsequently answer."; $headers = 'from: contact@yoursite.com'; mail($to, $subject, $msg, $headers); } else if($board=='bsw') { $to = 'email@rediffmail.com'; $subject = 'rti query: not reply email.'; $msg = $query; $headers = 'from: contact@yoursite.com'; mail($to, $subject, $msg, $headers); } else if($board=='bsa') { $to = 'email@iitd.ac.in'; $subject = 'rti query: not reply email.'; $msg = $query; $headers = 'from: contact@yoursite.com'; mail($to, $subject, $msg, $headers); } else if($board=='bsp') { $to = 'email@gmail.com'; $subject = 'rti query: not reply email.'; $msg = $query; $headers = 'from: contact@yoursite.com'; mail($to, $subject, $msg, $headers); } else if($board=='bhm') { $to = 'email@gmail.com'; $subject = 'rti query: not reply email.'; $msg = $query; $headers = 'from: contact@yoursite.com'; mail($to, $subject, $msg, $headers); } } if(mail($to, $subject, $msg, $headers)==true) { echo "the mail sent successfully."; } $conn1->close(); ?>
Comments
Post a Comment