Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3602228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:43:12+00:00 2026-05-18T20:43:12+00:00

I don’t know what’s wrong with my code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0

  • 0

I don’t know what’s wrong with my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>

<body>
<?php

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("dressoholic") or die(mysql_error()); 

if($_POST['form_submitted'] == '1'){

$actkey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
$birthdate = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];

$usrname = mysql_real_escape_string($_POST['uname']);
$pswd = mysql_real_escape_string($_POST['password']);
$emaill = mysql_real_escape_string($_POST['email1']);
# gender moet nog gedaan worden!!!
$sql = "INSERT INTO users(username, fname, lname, email, password, activationkey, bdate, status) VALUES
('$usrname','$_POST[fname]','$_POST[lname]','$emaill','$pswd','$birthdate','$actkey','verify')";

if (!mysql_query($sql))

  {

  die('Error: ' . mysql_error());

  }

  echo "An email has been sent to $_POST[email1] with an activation key. Please check your mail to complete registration.";

##Send activation Email

$to      = $_POST['email1'];

$subject = " Dressoholic.com Registration";

$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at Dressoholic.com. You can complete registration by clicking the following link:\rhttp://localhost/dressoholic/register.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ Dressoholic.com Team";

$headers = 'From: blabla@gmail.com' . "\r\n" .

    'Reply-To: blabla@gmail.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

} 
else {

##User isn't registering, check verify code and change activation code to null, status to activated on success

$queryString = $_SERVER['QUERY_STRING'];

$query = "SELECT * FROM users"; 

$result = mysql_query($query) or die(mysql_error());

  while($row = mysql_fetch_array($result)){

    if ($queryString == $row["activationkey"]){

       echo "Congratulations!" . $row["username"] . " is now the proud new owner of a Dressoholic.com account.";

       $sql="UPDATE users SET activationkey = '', status='activated' WHERE (id = $row[id])";

       if (!mysql_query($sql))

  {

        die('Error: ' . mysql_error());

  }

 }


}
}


?>

</body>
</html>

This is the exact error:

Error: Duplicate entry 'arnold-blabla@gmail.c-1987--22' for key 'username'

arnold is the username I entered.
blabla@gmail.com is the e-mail I entered.
1987 the year of birth and 22 the day!

I must say I am a beginner in PHP and MySQL. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:43:13+00:00Added an answer on May 18, 2026 at 8:43 pm

    You have a unique index in your users table on the username column. This means that two different users cannot have the same username.

    Enter a different username or remove the index, and you should be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know why, but this code worked for me a month ago... maybe
Don't know what's wrong here, when I run the application it says Specified method
Don't know if it's I'm doing it wrong or if there's a bug (I
Don't know if this is possible, but I have some code like this: val
don't know better title for this, but here's my code. I have class user
Don't know how to frase this but I found this code wich works as
don't know if the title describes anything about what I'm trying to say but
don't know what happened in my jcrop selection. I think I pressed some keys
Don't be scared of the extensive code. The problem is general. I just provided
Don't really know how to formulate the title, but it should be pretty obvious

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.