hi, i have a current working registration page, (the code is below), how do i make it so when they click register it checks to see if its a valid email address, if u cannot help me can u give me a link to a website. this registration form creates files instead of using a mysql database so i need the code to work with this registration page.

<?php
$errors = array();
if(isset($_POST['login'])){
	$username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
	$email = $_POST['email'];
	$password = $_POST['password'];
	$c_password = $_POST['c_password'];
	
	if(file_exists('users/' . $username . '.xml')){
		$errors[] = 'Username already exists';
	}
	if($username == ''){
		$errors[] = 'Username is blank';
	}
	if($email == ''){
		$errors[] = 'Email is blank';
	}
	if($password == '' || $c_password == ''){
		$errors[] = 'Passwords are blank';
	}
	if($password != $c_password){
		$errors[] = 'Passwords do not match';
	}
	if(count($errors) == 0){
		$xml = new SimpleXMLElement('<user></user>');
		$xml->addChild('password', ($password));
		$xml->addChild('email', $email);
		$xml->asXML('users/' . $username . '.xml');
		header('Location: register-complete.php');
		die;
	}
}
?>
<!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>
	<title>Registration</title>
	<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
    </script>
<style type="text/css">
<!--
.Apple {
	font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body class="Apple">
<table width="200" border="0">
  <tr>
    <td><form method="post" action="">
      <div align="center">
        <?php
		if(count($errors) > 0){
			echo '<ul>';
			foreach($errors as $e){
				echo '<li>' . $e . '</li>';
			}
			echo '</ul>';
		}
		?>
      </div>
      <p align="center" class="Apple"><strong><em>if you register with a fake email your account will be deleted </em></strong>.</p>
      <p align="center" class="Apple"><strong>Username
        <input type="text" name="username" size="20" />
      </strong></p>
      <p align="center"><strong>Email
        <input type="text" name="email" size="20" />
      </strong></p>
      <p align="center"><strong>Password
        <input type="password" name="password" size="20" />
      </strong></p>
      <p align="center"><strong>Confirm Password
        <input type="password" name="c_password" size="20" />
      </strong></p>
      <p align="center">
        <input type="submit" name="login" value="Register" />
      </p>
    </form></td>
  </tr>
</table>
</body>
</html>
if (!preg_match('/^.*?@[a-z]+\.[a-z]+$/i',$email){
// wrong email format
}

where about do i add the code you gave me ?, please help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.