Unable to get a post back from this code. Get a blank white page on return
尝试输入表单并将参数传递给查询db以获取用户ID的函数。编程为php的新手。用户名密码和数据库实际值已被删除
<?php
function capture_post_id($author_name_2, $project_name) {
$mysqli = new mysqli('localhost','username','password','database');
if ($mysqli->connect_error)
die('Error : ('. $mysqli->connect_error .') '. $mysqli->connect_error);
$product_name = $mysqli->query("SELECT ID FROM 'GoInst_posts' where post_name = $project_name AND post_author = $author_name_2")->fetch_object()- >product_name;
print $product_name; //output value
Global $row;
$row = mysqli_fetch_row($product_name);
mysqli_free_result($product_name);
$mysqli->close();
}
if (isset($_POST['val1']) && isset($_POST['val2'])) {
//$result = addNumbers(intval($_POST['val1']), intval($_POST['val2']));
$result = capture_post_id(intval($_POST['val1'], intval($_POST['val2'])));
}
?>
<html>
<body>
<?php if (isset($result)) { ?>
<h1> Result: <?php echo $result ?></h1>
<?php } ?>
<form action="" method="post">
author_name_2: <input type="text" name="val1"><br>
project_name: <input type="text" name="val2"><br>
<input type="submit">
</body>
</html>