<?php uid1= 1; $uid2= 2; ?>
<form class="contact" method="post">
<button value=" Send" class="btn btn-success" type="submit" id="submit">Add Friend</button></form>
if (isset($_POST['submit'])){
mysqli_query($mysqli, "INSERT INTO friends (uid1, uid2) values ('$uid1', '$uid2')") or die(mysql_error());
}
答案 0 :(得分:0)
在开场线..你错过了uid1的$。其次,您需要以hiddent文本发回值。
<?php $uid1= 1; $uid2= 2; ?>
<form class="contact" method="post">
<input type="hidden" name="uid1" value="<?= $uid1 ?>" />
<input type="hidden" name="uid2" value="<?= $uid2 ?>" />
<button value=" Send" class="btn btn-success" type="submit" id="submit">Add Friend</button></form>
if (isset($_POST['submit'])){
mysqli_query($mysqli, "INSERT INTO friends (uid1, uid2) values ('". $_POST["uid1"] ."', '". $_POST["uid1"] ."')") or die(mysqli_error());
}