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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -