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
Share on other sites

Can you being up any PHP pages? What happens if you upload a PHP info page?

 

Throw the following into notepad and save it as "info.php" and upload it to your site & try to open it in your browser:

 

<?php

  phpinfo();

?>

Link to comment
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";

}

 

Link to comment
Share on other sites

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) {

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

a) 1 and -1 are different! Change to 0 and 1 if desire!

b) There is an @ in the expression

 

Haha it works :)

 

lol got a birthdate function as well or do I gotta type one out? lol

 

Can I have premissions to use this on my site?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.