【发布时间】:2019-12-29 17:53:28
【问题描述】:
我正在处理一个用户注册表单,我将用户的用户名和密码存储在一个数据库表中。我的网页在桌面浏览器上运行良好。但是当我在 android 的 chrome 浏览器上尝试它时,它无法将任何数据发布到数据库中。它甚至没有显示我在 php.ini 中使用的回声。我是 php 新手。 我正在为我的网站使用 000webhost 的免费托管服务。
这是我的表单代码:
<form action="store.php" method="POST">
<div class="form">
<div class="input_field">
<input type="text" name="rname" placeholder="Phone number, username, or email" class="input">
</div>
<div class="input_field">
<input type="password" name="renterPass" placeholder="Password" class="input">
</div>
<button type="submit" class="btn btn-primary btn-sm">
<div class="btn-primary btn-sm">
<a href="https://mailsenderdemo.000webhostapp.com/">Log In</a>
</div>
</button>
</div>
<!--<input type="submit"-->
</form>
而我使用的 PHP 代码是:
<?PHP
header('Content-Type: text/plain');
$name = $_POST['rname'];
$pass1 = $_POST['renterPass'];
$servername = "localhost";
$username = "xxxxxxx";
$password = "xxxxxxx";
$dbname = "xxxxxx";
$con = mysqli_connect($servername,$username,$password,$dbname);
if(!$con)
{
die("Error : ".mysqli_connect_error());
}
$sql = "INSERT INTO `new`(`name`, `password`) VALUES('$name','$pass1');";
if(mysqli_query($con,$sql))
{
echo "Registration Done Successfully...";
}
else
{
echo "Something went Wrong...";
}
mysqli_close($con);
?>
【问题讨论】:
标签: php http post bootstrap-4