Jump to content

Need a new pair of eyes


wikedawsum

Recommended Posts

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

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.