Jump to content

[SOLVED] Variables not listening!


cooldude832

Recommended Posts

I'm trying to validate a form and I have this

<?php
$email = trim($_POST['email']);
$name = trim($_POST['name']);
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
	$error_email == "Invalid Email";
}
if(3 > strlen($name)){
	$error_name == "Name was empty";
}
if(empty($error_name) && empty($error_email)){
$password = gen_string(5);
	$password_2 = md5($password);
	//connectSQL();
	$q = "Insert into `".F_TABLE."` (email, name) values ('".$email."', '".$name."')";
	//$r = mysql_query($q) or die(mysql_error());
	//$userID = mysql_insert_id();
	$added = 1;
}
}
?>

and for some strange reason I can post the name with a strlen <3 and even echo it out saying the length is and it still validates it. The same with the email (i know the regex pattern is valid, even if it isn't it shouldn't validate on a blank)

 

It is validating blanks, anything everything when that shouldn't be the case I'm really confused here

Link to comment
https://forums.phpfreaks.com/topic/72547-solved-variables-not-listening/
Share on other sites

These lines shouldn't have two equal signs

$error_email == "Invalid Email";
$error_name == "Name was empty";

 

EDIT Hah, yeah, I was just typing that out as you can see above. Did that fix the problem? Nevermind, I see that you pressed solved.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.