Jump to content

checking if a record exists


pumaf1

Recommended Posts

hi,

I am writing a fantasy f1 system for 2008. What I have so far is the system taking the records perfectly fine but I want it to check to see if a few things have been duplicated

 

1 - username

the login system uses sessions and i have the users name as the team owners name. I want it to check to see if the user has already registered a team, and if so i want it to say "you already have a team."

 

2 - teamname

pretty much the same as the above - aka that team name is already in use.

 

I dont want it to check all the fields as some will be duplicates within the database. If anyone could point me in the right firection i would be really gratefull.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/71989-checking-if-a-record-exists/
Share on other sites

<?php

$sql = "SELECT *
        FROM table
        WHERE team_name = '$team_name';";

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

if(mysql_num_rows($result) > 0)
{
  // team already registered
}
else
{
  // team not registered
}

?>

 

Do the same thing for username.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.