shank888 Posted May 4, 2008 Share Posted May 4, 2008 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> "; ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted May 4, 2008 Share Posted May 4, 2008 Without having to comb through your code, can you please paste the exact error yo see...or possibly a screen shot of what's happening? Thanks. Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 Without having to comb through your code, can you please paste the exact error yo see...or possibly a screen shot of what's happening? Thanks. Quote Link to comment Share on other sites More sharing options...
Caesar Posted May 4, 2008 Share Posted May 4, 2008 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(); ?> Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 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"; } Quote Link to comment Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 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! Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 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) { Quote Link to comment Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 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 } Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 a) 1 and -1 are different! Change to 0 and 1 if desire! b) There is an @ in the expression Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 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? Quote Link to comment Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 it's now in the public domain so... er can't really stop you, but i'm sure it's not far off the wiki version or any of the ones in the php manual... What do you mean 'birthdate function'? Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 edit: someone can enter something like feburary 31st and get away with it. and other dates that dont exist Quote Link to comment Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 lookie, lookie Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 4, 2008 Author Share Posted May 4, 2008 lookie, lookie Cool thank you again! you are of great help and knowledge Quote Link to comment Share on other sites More sharing options...
wrathican Posted May 4, 2008 Share Posted May 4, 2008 hmm, awesome. ive juat found an easy way to check if a date is correct thanks alot! Quote Link to comment Share on other sites More sharing options...
shank888 Posted May 5, 2008 Author Share Posted May 5, 2008 hmm, awesome. ive juat found an easy way to check if a date is correct thanks alot! that is why I made that thread lol p.s this thread is solved i dunno who does this. Quote Link to comment Share on other sites More sharing options...
Coreye Posted May 5, 2008 Share Posted May 5, 2008 p.s this thread is solved i dunno who does this. You do by pressing the "Topic Solved" button. You'll find an option at the bottom of the thread that reads "Topic Solved". http://www.phpfreaks.com/forums/index.php/topic,118755.0.html. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.