Answer to Question #240865 in C++ for Thrinesh

Question #240865

Write a PHP page where you press a button and a value is entered into data base table

Then write a python or c script that reads the first line of the table

On button 1 must be entered into the table

Off then a 0 must be entered

Use update SQL queries instead of insert


1
Expert's answer
2021-09-23T00:26:53-0400
<?php


$conn = mysqli_connect("127.0.0.1", "root", "", "test");


if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
else{
	echo "Connected to the successful!";
	$data =  $_REQUEST['one_value'];
	$query = "INSERT INTO `test`(`value_0_1`) VALUES ('$data')";
	$sql = "UPDATE test SET value_0_1=1 WHERE id=2";
	 if(mysqli_query($conn, $query)){
     echo "Inserted successfully!";
	 }
}


?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
<h1>Inserting data to database</h1>
<form method="POST" action="connect_to_db">
	
	<div name="one_value">1</div>
	<div name="zero_value">1</div>
	<input type="submit" value="Submit">
</form>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS