如何在此代码中添加重复功能以进行电子邮件重复?
我有检查电子邮件的功能是否已存在于数据库中,但我想再次使用电子邮件功能来重新输入电子邮件。我怎样才能在我的代码中做到这一点。谁能帮我吗?
<?php
include("includes/connect.php");
if(isset($_POST['submit'])) {
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
$... = $_POST['...'];
if($...=='') {
echo"<script>alert('please enter the ...')</script>";
exit();
}
if($...=='') {
echo"<script>alert('please enter the ...')</script>";
exit();
}
if($...=='') {
echo"<script>alert('please enter the ...')</script>";
exit();
}
if($...=='') {
echo"<script>alert('please enter the ...')</script>";
exit();
}
$check_... = "SELECT * FROM ... where ...='$...'";
$run = mysql_query($check_...);
if(mysql_num_rows($run)>0) {
echo "<script>alert('... $... is alredy exist in database , please try other ...')</script>";
exit();
}
$query ="INSERT INTO ... (...,...,..., ...,...,...,...,...,...) VALUES ('$...','$...','$...', '$...','$...','$...','$...','$...,'$...')";
if(mysql_query($query)) {
echo "<script>alert('Registiration was succesfully!')</script>";
}
}
?>
最佳答案
我希望这不是生产代码,因为代码具有潜在的 SQL 注入(inject)(请检查此 What is SQL injection? )。但无论如何关于你的问题。您需要添加简单的检查来实现您想要的:
...
if($business_name == ''){
echo"<script>alert('please enter the usernme')</script>";
exit();
}
if($email == ''){
echo"<script>alert('please enter the email')</script>";
exit();
}
//check for matching
if($email != $emailagain){
echo"<script>alert('entered email addresses don't match')</script>";
exit();
}
$check_email = "SELECT * FROM ... where ...='$...'";
...
关于php - 在 php 中重复发送电子邮件以获取注册表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20363840/