誰かが助けてくれるかどうか疑問に思っていました(この主題が以前に提起されたことを知って申し訳ありません)
サインアップ フォームを提出する前に、会社と電子メール アドレスが存在しないことを確認したい。
どんな助けにも感謝します。
テーブル名は R_TABLE で、フィールドは COMPANY です テーブル名は U_TABLE で、フィールドは EMAIL です
<?
session_start();
//ignore this -->$email = $_POST['email'] ;
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
//Connect to Database
include('includes/dbconn.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sign Up Form</title>
<link rel="shortcut icon" href="favicon.ico" />
<link href="eps.css" rel="stylesheet" type="text/css" />
<div class="header2">
</div>
//VALIDATES FIELDS
<script language="javascript">
function validateForm()
{
var x=document.forms["form1"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
if (document.forms["form1"]["email"].value != document.forms["form1"] ["email2"].value) {
alert("Email addresses do not match");
return false;
}
{
var x=document.forms["form1"]["companyName"].value;
if (x==null || x=="")
{
alert("Please enter your company name.");
return false;
}
}
}
</script>
</head>
<body background="images/background.gif" repeat >
<table width="1101" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<br/> <br/>
<p align="center" class="SignUpText">Sign Up Form</p>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="TableBorder">
<tr>
<td>
<form id="form1" name="form1" method="post" action="signup.php" onSubmit="return validateForm();">
<input name="a" type="hidden" id="a" value="signup" />
<input name="group" type="hidden" id="group" />
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="MainText">
<tr>
<td colspan="4" class="auto-style4" style="height: 40px"><strong>
<span class="auto-style5">Personal Information</span><br/>
</tr>
//COMPANY NAME
<tr>
<td width="25%">Company Name</td>
<td style="width: 2%">*</td>
<td width="25%"><label>
<input name="companyName" type="text" class="auto-style3" id="companyName" size="35" /></label></td>
<td style="width: 2%"><a href="#" class="hintanchor" onMouseover="showhint('Please enter your registered company name.', this, event, '150px')">?</a></td>
//EMAIL
<td>
<input name="email" type="text" class="auto-style3" id="email" size="40" /></td>
<tr>
<td>Re-enter Email Address</td>
<td style="width: 2%">*</td>
<td>
<input name="email2" type="text" class="auto-style3" id="email2" size="40" /> </td>
//SUBMIT
<tr>
<td colspan="4"><div align="center">
<input type="submit" name="Submit" value="Sign Up" />
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Here is part of the class that adds new users, the email actually is added to contactEmail field , company is added to companyname within the database which I need to check if it doesn't already have the email and company name stored
function addmember($companyname, $licencenumber,$companyNumber,$vatNumber,$address1,$address2,$address3,$town,$county,$postcode,$firstname,$surname,$email,$phone,$training,$norepairs,$logo,$repairtype,$repairgroup,$mode)
{
$ref = "REP";
$licencenumber = "TEST";
$query = "INSERT INTO r_table VALUES ";
$query.= "(NULL,";
$query.= "\"$ref\",";
$query.= "\"$companyname\",";
$query.= "\"$licencenumber\",";
$query.= "\"$companyNumber\",";
$query.= "\"$vatNumber\",";
$query.= "\"$address1\",";
$query.= "\"$address2\",";
$query.= "\"$address3\",";
$query.= "\"$town\",";
$query.= "\"$county\",";
$query.= "\"$postcode\",";
$query.= "\"$firstname\",";
$query.= "\"$surname\",";
$query.= "\"$email\",";
$query.= "\"$phone\",";
$query.= "\"$training\",";
$query.= "\"$norepairs\",";
$query.= "\"$logo\",";
$query.= "\"$repairtype\",";
$query.= "\"$repairgroup\",";
$query.= "NOW(),";
$query.= "NOW(),";
$query.= "$mode)";
$result = mysql_query($query);
$insertid = mysql_insert_id();
$ref = "REP".$insertid;
$licencenumber = "test".$insertid;
$query = "UPDATE r_table SET ref = \"$ref\", licenseNumber=\"$licencenumber\" WHERE id = ".$insertid;
$result = mysql_query($query);
echo mysql_error();
if (!$result)
echo mysql_error();
else
return $ref;