[PHP] function doesn't return value

2003-06-28 Thread anders thoresson
Hi,

After a new user has filled in a form to register for my site, I check 
that she has entered the same password twice by calling a homemade 
function. Like this:

$u_pwd = validate_password($_POST['u_pwd'],$_POST['u_pwd1']);

And the function looks like this:

function validate_password($unchecked_password1, $unchecked_password2, 
$errortype = 1, $errormessage = Password must contain just letters and 
figures.) {
	
	if(!($unchecked_password1 == $unchecked_password2)) {
			error(Passwords entered doesn't match!);
		}

if(!ereg((^[a-zA-ZåÅäÄöÖ0-9]{6,15}$), $unchecked_password2)) {
if($errortype == 1) {
error($errormessage);   
}
Return 1;
}

}
I have verified that $_POST['u_pwd'] and $_POST['u_pwd1'] as well as 
$unchecked_password1 and $unchecked_password2 contains the entered values, 
but $u_pwd is empty.

Why?

As with my previous problems this evening, it works on my local server, 
but not on my ISP's. At home I'm running Windows 2000 and PHP 4.3.1, while 
my ISP is on SunOS 5.7 with PHP 4.1.1.

--
anders thoresson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] function doesn't return value

2003-06-28 Thread Jason Wong
On Sunday 29 June 2003 02:53, anders thoresson wrote:

  After a new user has filled in a form to register for my site, I check
 that she has entered the same password twice by calling a homemade
 function. Like this:

  $u_pwd = validate_password($_POST['u_pwd'],$_POST['u_pwd1']);

  And the function looks like this:

 function validate_password($unchecked_password1, $unchecked_password2,
 $errortype = 1, $errormessage = Password must contain just letters and
 figures.) {

   if(!($unchecked_password1 == $unchecked_password2)) {
   error(Passwords entered doesn't match!);
   }

   if(!ereg((^[a-zA-ZåÅäÄöÖ0-9]{6,15}$), $unchecked_password2)) {
   if($errortype == 1) {
   error($errormessage);
   }
   Return 1;
   }

 }

  I have verified that $_POST['u_pwd'] and $_POST['u_pwd1'] as well as
 $unchecked_password1 and $unchecked_password2 contains the entered values,
 but $u_pwd is empty.

  Why?

AFAIK in PHP, if you don't specifically return something from a function, the 
function will not return anything.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Smear the road with a runner!!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] function doesn't return value

2003-06-28 Thread anders thoresson
AFAIK in PHP, if you don't specifically return something from a function, 
the function will not return anything.
True. I'm so frustrated over here that I miss the most obvious things. 
Thank's.

Strange thing is that it worked at my localhost, though.

--
anders thoresson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] function doesn't return value

2003-06-28 Thread electroteque
try return true;

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 29, 2003 5:37 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] function doesn't return value


On Sunday 29 June 2003 02:53, anders thoresson wrote:

  After a new user has filled in a form to register for my site, I check
 that she has entered the same password twice by calling a homemade
 function. Like this:

  $u_pwd = validate_password($_POST['u_pwd'],$_POST['u_pwd1']);

  And the function looks like this:

 function validate_password($unchecked_password1, $unchecked_password2,
 $errortype = 1, $errormessage = Password must contain just letters and
 figures.) {

   if(!($unchecked_password1 == $unchecked_password2)) {
   error(Passwords entered doesn't match!);
   }

   if(!ereg((^[a-zA-ZåÅäÄöÖ0-9]{6,15}$), $unchecked_password2)) {
   if($errortype == 1) {
   error($errormessage);
   }
   Return 1;
   }

 }

  I have verified that $_POST['u_pwd'] and $_POST['u_pwd1'] as well as
 $unchecked_password1 and $unchecked_password2 contains the entered values,
 but $u_pwd is empty.

  Why?

AFAIK in PHP, if you don't specifically return something from a function,
the
function will not return anything.

--
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Smear the road with a runner!!
*/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php