0

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>
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by tomjrjones
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.