这是代码,不起作用 -
<form method="post">
<input type="submit" name="zapis" id="zapisk" value="Запис" /><br/>
</form>
<?php
function zapisk()
{$servername = "localhost";
$username = "test";
$password = "";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
//{echo "Your test function on button click is working";}
//if(array_key_exists('zapis',$_POST)){zapisk();}
?>
如果我激活最后两行,此时作为评论,该功能将起作用。是否有可能,该功能可以在不使用最后两行的情况下工作。
天涯尽头无女友