wikedawsum Posted February 8, 2008 Share Posted February 8, 2008 I'm going nuts trying to figure this out and thought a new pair of eyes might help. Can anyone tell me why this registration function for one of my websites would suddenly stop working? It has been working great for over a year, and recently anytime someone tries to register they get the error "Could not register you in the database. Please try again later." (which you will see below). I haven't made any changes to it, or any changes to my database. If you guys can offer any input I'd really appreciate it. Registration Form: <form method="post" action="register_new.php"> First Name:<br /> <input type="text" name="fname" size="25" maxlength="50"><br /> Last Name:<br /> <input type="text" name="lname" size="25" maxlength="50"><br /> Company Name:<br /> <input type="text" name="cname" size="25" maxlength="50"><br /> Email Address:<br /> <input type="text" name="email" size="25" maxlength="100"> (A valid email address is required.)<br /> Username:<br /> <input type="text" name="username" size="25" maxlength="50"> (Must be no longer than 16 characters.)<br /> Password:<br /> <input type="text" name="passwd" size="25" maxlength="50"> (Must be between 3 and 30 characters.)<br /> Confirm Password:<br /> <input type="text" name="passwd2" size="25" maxlength="50"><br /> <INPUT TYPE="submit" NAME="submit" VALUE="Submit" style="font-family: Tahoma"> </form> register function function register($fname, $lname, $cname, $email, $username, $passwd) { $conn = db_connect(); $result = $conn->query("select * from user where username='$username'"); if (!$result) throw new Exception('Could not execute query'); if ($result->num_rows>0) throw new Exception('That username is taken. Go back and choose another one.'); $result = $conn->query("insert into user (fname, lname, cname, email, username, passwd) values ('$fname', '$lname', '$cname', '$email', '$username', sha1('$passwd')"); if (!$result) throw new Exception('Could not register you in the database. Please try again later.'); else { $mailheaders = "From: ********.com\n"; $mailheaders .= "A new user has registered at *******.com.\n\n"; $mailheaders .= "Information about the user:\n"; $mailheaders .= "Name: $_POST[fname] $_POST[lname]\n"; $mailheaders .= "Company Name: $_POST[cname]\n"; $mailheaders .= "Username: $_POST[username]\n"; $mailheaders .= "Password: $_POST[passwd]\n"; $mailheaders .= "E-Mail Address: $_POST[email]\n"; $to = "*******@********.com"; $subject = "New Registration Alert"; mail($to, $subject, $mailheaders, "From: ****** ****** *******@********.com\n");} return true; } Again, thank you to anyone who can shed some light on this! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 How do you invoke the function? Has anything changed on the server where the script is being run? Ken Quote Link to comment Share on other sites More sharing options...
wikedawsum Posted February 8, 2008 Author Share Posted February 8, 2008 Hello, Ken. When a user clicks submit, it processes a script called register_new.php. Inside this, I have an include for user_auth_fns.php. This is where the register function is stored. register_new.php does some checking on the form side (passwords match, username length, valid email, etc.). If that all checks out it is then supposed to run the register function. I personally have not changed anything on the server. The web hosting for this site is through Dreamhost. Is it possible that they have changed something that would cause this script to malfunction? Thank you! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 The could have upgraded PHP to v5 and turned off register_globals. Ken Quote Link to comment Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Share Posted February 8, 2008 HI I would go with kenrbnsn run phpinfo() to check BTW - that code style is pretty old school if your ISP has turned off register_globals, which would be a sensible thing to do, you can usually get old code working with a single line.... extract($_POST); see extract docs for details HTH Quote Link to comment Share on other sites More sharing options...
wikedawsum Posted February 8, 2008 Author Share Posted February 8, 2008 Thank you both. I'll check on this and see what I can find. 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.