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> "; ?> Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/ 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. Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532882 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. Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532883 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(); ?> Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532886 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"; } Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532904 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! Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532910 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) { Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532918 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 } Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532922 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. Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532924 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 Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532943 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? Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532947 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'? Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532952 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 Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532959 Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 lookie, lookie Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532968 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 Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-532973 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! Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-533014 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. Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-533151 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. Link to comment https://forums.phpfreaks.com/topic/104096-solved-register-script/#findComment-533171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.