Jump to content

[SOLVED] Register script


shank888

Recommended Posts

Hey all.

 

For sum reason when I try to acess my register script my server comes up saying service is unavalible.  I know my server works for other pages and I am thinking it is the script that is causing this problem. Here is the script below.  As well does anyone have any security pointers for me?

 

<?php
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) {
$problem = FALSE; // no problems so far

if (empty ($_POST['username'])) {
	$problem = TRUE;
	print "<p>Please enter a username.</p>";
	}

if (empty ($_POST['password'])) {
	$problem = TRUE;
	print "<p>Please enter a password</p>";
	}

if ($_POST['password'] != $_POST['cpassword']) {
	$problem = TRUE;
	print "<p>Your Passwords did not match.</p>";
	}

if (!problem) { // If no problems occured
print "<p>You have now been registered!</p>";

}
function validateEmail($email) {  
    if (eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)",  
$email) || !eregi ("^.+\@(\[?)[-_a-zA-Z0-9\.]+\.([a-zA-Z] 
{2,3}|[0-9]{1,3})(\]?)$", $email)) {  

return 1;  
    } 

    else {  
        list($user, $domain) = explode(`@`,  
$email);  
        if ((!eregi("^[_a-zA-Z0-9\.\-]+$",  
$user)) || (!eregi("^[_a-zA-Z0-9\.\-]+$", $domain))) {  

            return 1;  
        }  
        else {  
            return 0;  
        }  
    } 
} 

if (validateEmail($email) == 1 || validateEmail($email) ==0) {
print " E-mail is not in correct format";
}
}

// Displaying HTML form below
print "
<form action='register.php' method='post'>
Username: <input type='text' name='username' size='20' />
<br />
E-mail: <input type='text' name='email' size='20' />
<br />
Password: <input type='password' name='password' size='20' />
<br />
Confirm Password: <input type='password' name='cpassword' size='20' />
<br />
<input type='submit' name='submit' value='register' />
</form>
";
?>

Link to comment
https://forums.phpfreaks.com/topic/104096-solved-register-script/
Share on other sites

hmm okay, as it seems my PHP-cgi.exe wasn't opening, it works now. exept the script it always says my e-mail is not in correct format.

 

I have a feeling it resides in the line here:

 

if (validateEmail($email) == 1 || validateEmail($email) ==0) {

print " E-mail is not in correct format";

}

 

That statement says:

Whether it's right or wrong, say it's wrong...

Try:

if (validateEmail($email) == 1) {
   print " E-mail is not in correct format";
}

or the other one!

 

 

The following code:

if (validateEmail($email) == 1) {

Makes the statment always say the e-mail is of an incorrect format wether it be true or not.

 

The code:

if (validateEmail($email) == 0) {

Makes the statement always say the e-mail is of correct format

if (validateEmail($email) == 1) {

Without looking that tells me that the function is incorrect? Here's what I use:

function scheck_email($email)
{
if(eregi("[A-Z0-9._%-]+@[A-Z0-9.-]{2}([A-Z0-9.-])?\.[A-Z]{2,4}",$email))
	return 1;	//	valid
return -1;		//	invalid
}

 

okay I am not too good with expressions and functions. umm can you explain the return 1 and return -1. I always thought you need a different return for each expression?

 

Edit. Also your version does not include if there is an @ in it and splits it up more. if i am making sence.

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.