【发布时间】:2014-10-11 08:12:59
【问题描述】:
我希望系统在发生新注册时检查 xml 文件中是否存在电子邮件,我该怎么做?我有了比较所有电子邮件节点的基本想法,但几个小时后仍然无法让它工作。感谢您的帮助
注册.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<h1>ShipOnline System Registration Page</h1>
<form id="regform" method="post" action="register.php">
<fieldset id="person">
<legend>Your details:</legend>
<p><label for="fname">First Name:</label><input type="text" name="fname"/></p>
<p><label for="lname">Last Name:</label><input type="text" name="lname"/></p>
<p><label for="password">Password:</label><input type="password" name="password"/></p>
<p><label for="cpassword">Confirm Password:</label><input type="password" name="cpassword"/></p>
<p><label for="email">Email:</label><input type="email" id="email" name="email"/></p>
<p><label for="phone">Phone:</label><input type="text" name="phone"/></p>
<input type="submit" value="Register"/>
</fieldset>
</form>
</body>
</html>
register.php的相关部分
<?php
$email = @trim($_POST["email"]);
if ($password != $cpassword)
{
echo 'Password does not match';
}
@override
else if ($email /*exists*/)
{
echo 'Email exists';
}
?>
客户.xml
<?xml version="1.0"?>
<customer>
<user>
<id>0</id>
<fname>John</fname>
<lname>Smith</lname>
<email>jsmith@gmail.com</email>
<password>jsmith</password>
<phone>0412345677</phone>
</user>
<user>
<id>1</id>
<fname>Arthur</fname>
<lname>Luo</lname>
<email>aluo@gmail.com</email>
<password>aluo</password>
<phone>0412345678</phone>
</user>
【问题讨论】: