This question already has an answer here:
- query an XML file using PHP 2 answers
I want the system to check whether the email exists in the xml file when a new registration occurs, how can I do that? I got the basic idea of comparing all the email nodes but still cant get it to work after several hours. Thanks for the help
register.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>
relevant parts of register.php
<?php
$email = @trim($_POST["email"]);
if ($password != $cpassword)
{
echo 'Password does not match';
}
@override
else if ($email /*exists*/)
{
echo 'Email exists';
}
?>
customer.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>
</div>