【发布时间】:2021-02-18 18:43:05
【问题描述】:
这是我的 sql:
<?php
$db=pg_connect("host=localhost port=5432 dbname=postgres user=postgres password=preethy1970");
if (isset($_POST['signup'])) {
$query = "INSERT INTO users(user_name,user_password,user_email,user_phone,user_type) VALUES('$_POST[name1]','$_POST[password]','$_POST[email]','$_POST[phoneNumber]','$_POST[usertype]')";
$result=pg_query($query);
}
?>
这里是html:
<form method="post" action="signUp.php">
<input id="submit-form" name="name1" placeholder="Name" type="text" required></input>
<input id="submit-form" name="email" placeholder="Email id" type="email"></input>
<input id="submit-form" name="phoneNumber" placeholder="Phone Number" type="tel"></input>
<input id="submit-form" name="password" placeholder="Password" type="password"></input><br>
<input name="usertype" type="radio" value="0">Student</input>
<input name="usertype" type="radio" value="1">Faculty</input>
<input name="usertype" type="radio" value="2">Alumni</input>
<input id="submit-btn" type="submit" name="signup" value="Sign Up"></input>
</form>
所以我将转到我的注册页面并添加一些内容,这些内容将添加到用户表中。当我重新加载页面时,即使字段为空且未单击提交按钮,先前的内容也会再次添加为新行。为什么会这样?
【问题讨论】:
标签: php database postgresql