Question: Write a prepared statement for the below code $name = mysql_real_escape_string(htmlentities($_POST['name'])); $content = mysql_real_escape_string(htmlentities($_POST['content'])); $submit = mysql_real_escape_string(htmlentities($_POST['submit'])); echo $username; if(isset($submit)) { if($name && $content){ $sql

Write a prepared statement for the below codeWrite a prepared statement for the below code $name = mysql_real_escape_string(htmlentities($_POST['name'])); $content

$name = mysql_real_escape_string(htmlentities($_POST['name'])); $content = mysql_real_escape_string(htmlentities($_POST['content'])); $submit = mysql_real_escape_string(htmlentities($_POST['submit'])); echo "$username"; if(isset($submit)) { if($name && $content){ $sql = "INSERT INTO posts (title, content, time, owner) VALUES ('$name', '$content', now(), '$username')"; $result = $mysqli->query($sql); if($result){ echo "Your reply has been saved"; header ('Location: index.php'); } else{ echo $result; echo "problem with query"; } } else{ echo "one or more fields are empty"; } } else { echo "Your reply has been saved, ";

}

?php require auth.php $mysqli new mysqli(' localhost root 'seedubuntu', project mysql connect error die(' Connection to the database has error: $mysqli connect error) $nane nysgl real escape string(htnlentities($ POSTC 'name $content mysql real escape string (htnlentities POST content $submit mysql real escape string (htnlentities($ POSTC' subnit'])) echo $username if(isset ($submit)) if ($nane && Scontent)f ..i $segl INSERT INTO posts (title content, tine, owner) VALUES ('Snane 'Scontent', now(), 'Susernane $result $nysqli- query ($sql) if $result) echo Your reply has been saved header ('Location: index.php'); else{ echo result echo "problem with query"; else{ echo one or nore fields are empty else echo "Your reply has been saved

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!