沃梦达 / 编程问答 / php问题 / 正文

PHP 在数据库中插入重复项

PHP Inserting Duplicates In DB(PHP 在数据库中插入重复项)

本文介绍了PHP 在数据库中插入重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个注册页面,当前代码运行正常,但我在数据库端收到重复插入.我已经研究并尝试了几种不同的解决方案,但还没有成功.我希望它是我所缺少的非常简单的东西.如何防止我当前的代码插入两次?

I'am attempting to build a register page and the current code runs correctly but I'am getting duplicate inserts on the DB side. I've researched and have tried several different solutions but nothing has worked out yet. I'm hoping its something very simple that I'am missing. How can I prevent my current code from inserting twice?

<?php
session_start();
$error=''; // Variable To Store Error Message
if (isset($_POST['register'])) {
//if (empty($_POST['email']) || empty($_POST['hash'])) {
//$error = "<br /> <p style='font-family:talo; color:red; margin-top:10px; font-size:16px;'>* Username or Password is invalid</p>";
/

本文标题为:PHP 在数据库中插入重复项

基础教程推荐