0

I have a registration page and I want to validate the e-mail address. I'm having an issue with line 14 in particular. (I used a combination of several tutorials to make this).

<?php 
include("db.php"); 

if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
 
{ 

$username = mysql_real_escape_string($_POST['username']); 
$email = mysql_real_escape_string($_POST['email']); 
 
$result=ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$",$email,$trashed);
if(!$result){
echo "Enter a valid E-mail Address";
displayForm("register");
}

$password = md5($_POST['password']); 
$ip = $_SERVER['REMOTE_ADDR'];

$sql = mysql_query("SELECT username FROM usersystem WHERE username = 'username'");

If (mysql_num_rows($sql) >0) 

{ 
die ("Username is already taken."); 
}
 
 
mysql_query("INSERT INTO usersystem (username, password, email, ipadd) VALUES ( '$username', '$password', '$email', '$ip')") or die (mysql_error()); header("Location: login1.php");
 }

?>



<html><form action="register.php" method="post" name="register">
Username: <input name="username" type="text" />
Password: <input type="password" name="password" />
Email: <input name="email" type="text" />
<input type="submit" value="Submit"/>
</form>
</html>

If I leave line 14 in the code, when an invalid e-mail address comes up, it redirects to a new page and the message is: Enter a valid E-mail Address
Fatal error: Call to undefined function displayform() in /home/.../register.php on line 14

If I remove it (because I am honestly not sure why it is necessary) it does not check for a valid format on the e-mail addresses.


Any ideas?

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by P0lT10n
This question has already been answered. 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.