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

  • Home
  • SEARCH
  • 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 8518449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:58:50+00:00 2026-06-11T05:58:50+00:00

I am trying to build an application that allows users to submit names to

  • 0

I am trying to build an application that allows users to submit names to be added to a db table (runningList). Before the name is added tho, I would like to check firstname and lastname against another table (controlList). It must exist in (controlList) or reply name not valid. If the name is valid I would like to then check firstname and lastname against (runningList) it make sure it isnt already there. If it isn’t there, then insert firstname & lastname. If it is there, reply name already used.

Below is code that worked before I tried to add the test against the controlList,
I somehow broke it altogether while trying to add the extra step.

if (mysql_num_rows(mysql_query('SELECT * FROM runninglist WHERE firstname=\'' .$firstname . '\' AND lastname=\'' . $lastname . '\' LIMIT 1')) == 0)
{
 $sql="INSERT INTO runninglist (firstname, lastname)
 VALUES ('$_POST[firstname]','$_POST[lastname]')";
}
else
{
echo "This name has been used.";
 }

Any suggestion?

  • 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-06-11T05:58:51+00:00Added an answer on June 11, 2026 at 5:58 am

    Create a “unique” index on (firstname, lastname).

    Then, when the insert runs it will fail. Just ignore the error (or take other action)


    Edit: quote from the manual:

    A UNIQUE index creates a constraint such that all values in the index
    must be distinct. An error occurs if you try to add a new row with a
    key value that matches an existing row.

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

Sidebar

Related Questions

I'm trying to build an application that allows users to drag files from Finder
We are trying to build an web application that allows users to select appropriate
I'm trying to build a application that has different kinds of users, I'm using
I'm trying to build a simple GAE application that would read a textbox, pass
I'm trying to build a application that allows the user to either A) enter
We are trying to build a silverlight application that allows a user to stream
New ROR programmer here. I'm trying to build a web application that allows a
I'm trying to build application that could help me dial a contact just like
I'm trying to build an application that builds a resource file into a jar,
i'm trying to build an application that every given time, will connect to a

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.