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 7704177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:37:39+00:00 2026-05-31T23:37:39+00:00

Hi i am getting error while putting validations for email in PHP5.2 see my

  • 0

Hi i am getting error while putting validations for email in PHP5.2
see my below code: i have called checkemail() and written function checkemail() in script. but i am getting error like Error: Duplicate entry ” for key ‘PRIMARY’ as i have declare email id as primary key. when i put anything in email id then it accepting in database. i think function is not executing properly. guide if have suitable solutions.if required any details then let me know.

<head>
<script>
  function checkEmail()
  {
    $strEmail= mysql_real_escape_string($_POST['email']);
    if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $strEmail))
    {
      return true;
    }
    else
    {
      return false;
    }
  }
</script>
</head>
<body>
  <div class="container">
    <section id="content">
      <form name="form1" method="post" action="check_register.php">
        <div>
          <input type="text" placeholder="Enter username" required="" id="uname" name="uname"/>
        </div>
        <div>
          <input type="text" placeholder="Enter Email-id" required="" id="email" name="email" onfocus="checkEmail('email');"  />
        </div>
        <div>
          <input type="password" placeholder="Enter Password" required="" id="pass" name="pass"/>
        </div>
        <div>
          <input type="password" placeholder="Repeat Password" required="" id="rpass" name="rpass" onfocus="checkPassword(document.getElementById('pass'), this);" oninput="checkPassword(document.getElementById('pass'), this);"/>
        </div>
        <div>
          <input type="text" placeholder="Enter country" required="" id="country" name="country"/>
        </div>
        <div>
          <input type="submit" value="Register"  />
        </div>
      </form>
    </section>
  </div>
  <script src="form-validation.js"/></script>
</body>
  • 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-31T23:37:40+00:00Added an answer on May 31, 2026 at 11:37 pm

    Do you check if the mail already exists in the database before trying to insert it ? I think you problem is here. No matters html5 or validation of the email.

    And by the way, please never use <script> balise to execute php code. Use <?php /* your code here */ ?> instead.

    You can also use a built-in PHP function to validate your email using filter_var, check the first example: http://www.php.net/manual/en/filter.examples.validation.php

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

Sidebar

Related Questions

I am getting an error while trying to run CFmx code on a remote
I keep getting this error while trying to modify some tables. Here's my code:
Getting this error while compiling C++ code: undefined reference to `__stack_chk_fail' Options already tried:
I'm getting error while using php function copy() Warning: copy() [function.copy]: Couldn't resolve host
I am getting this error while running my app on the device.I have installed
I am getting an error while assigning a value. My code is: protected bool
getting error while try to start service
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
I'm getting an error while trying to use the action_mailer_tls plugin to communicate with
All of a sudden I start getting this error while trying to open 2

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.