Jump to content

Enter new information into an established database


Jim R

Recommended Posts

Not sure how to even search for what I'm looking for, which is to say I'm really in need of guidance. 

 

I have a pre-populated database that I set up with about 260 names in it.  It also has information like, height (basketball players) and high school.  It's a list of kids I mean to invite to play in a league.  From there, they will actually come to the league's site and register.

 

I'd like for my form to check to see if they are already in the database, and if they are just add personal information, like email and phone number.  If they are not, I'd like for the form to enter all of the information (name, school, etc).

 

Link to comment
Share on other sites

I haven't tried any code for this specifically, mostly because I'm not sure where to start.  Here is the code I use for the form I have set up now, which enters all information into a second database. 

 

I'd like to check the database I have set up for invitees, and if there is already a record of that player, update his entry with the additional information asked for in the form.

 

<form id="entryFall" action="/form/dbenter.php" method="post">
<table border="0" width="500">
<tbody>
<tr>
<td colspan="4">
<div><strong><span style="font-size: x-small;">Fall Varsity League</span></strong></div></td>
</tr>
<tr>
<td colspan="4">
<div style="text-align: center;"><strong>Online Entry Form </strong>
Address and phone information made available only to college coaches.
If you have already registered and are trying to pay online, please click the Payment link above in the Fall League menu.</div></td>
</tr>
<tr>
<td><strong>First Name*:</strong></td>
<td colspan="3"><input maxlength="30" name="nameFirst" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>Last Name</strong>*:</td>
<td colspan="3"><input maxlength="30" name="nameLast" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>Email*:</strong></td>
<td colspan="3"><input maxlength="50" name="email" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>Address:</strong></td>
<td colspan="3"><input maxlength="50" name="addressHome" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>State:</strong></td>
<td colspan="3"><input maxlength="5" name="stateHome" size="2" type="text" /></td>
</tr>
<tr>
<td><strong>Zip:</strong></td>
<td colspan="3"><input maxlength="5" name="zipHome" size="6" type="text" /></td>
</tr>
<tr>
<td><strong>Home Phone*:</strong></td>
<td colspan="3"><input maxlength="13" name="phoneHome" size="13" type="text" /></td>
</tr>
<tr>
<td><strong>Mobile Phone</strong>*:</td>
<td colspan="3"><input maxlength="13" name="phoneMobile" size="13" type="text" /></td>
</tr>
<tr>
<td><strong>High School*:</strong></td>
<td colspan="3"><label></label>

<input maxlength="30" name="school" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>Grade*:</strong></td>
<td colspan="3"><input maxlength="2" name="grade" size="5" type="text" /></td>
</tr>
<tr>
<td><strong>Varsity Coach*: </strong></td>
<td colspan="3"><input maxlength="30" name="coachSchool" size="30" type="text" /></td>
</tr>
<tr>
<td><strong>Feet*:</strong></td>
<td width="10%"><input maxlength="1" name="feet" size="3" type="text" /></td>
<td width="13%"><strong>Inches*:</strong></td>
<td width="51%"><input maxlength="2" name="inches" size="3" type="text" /></td>
</tr>
<tr>
<td></td>
<td colspan="3"><input name="success" type="hidden" value="http://www.indybasketballevents.com/thankyou.php" /> * required</td>
</tr>
<tr>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td></td>
<td colspan="3"><label for="Submit"></label>

<input id="Submit" name="Submit" type="submit" value="Submit" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody></table>
</form>

Link to comment
Share on other sites

obviously, there needs to be some unique 'identifier(s)' about a player to properly check if already exists. ie a combination of last, first, middle names plus his school should suffice

 

psuedo code...

 

select from database records where database lastname = form value lastname AND  database firstname = form value firstname AND  database middlename = form value middlename AND database school = form value school.

 

(of course it is POSSIBLE that two players could have identical names AND attend same school - so this may need some refining ie dob)

 

Link to comment
Share on other sites

very broad process...

1. get the form data (cleanse)

2. query database to see if student is already in database

3. if NOT in database, add player to the data base ( use INSERT)

4. do whatever else you want (perhaps if student WAS already in database, up date with current info)

 

Link to comment
Share on other sites

Knowing the players very well, there won't be an instance where there is identical player names at different schools, let alone the same schools, so I would be safe there.  From there, what you're saying is I'm checking the data already there, and if it finds identical information, I need to UPDATE, and if I don't, I need to INSERT?

 

 

 

 

Link to comment
Share on other sites

you can count the number of rows returned by your query, if the person already exists the number of rows should equal 1

 

psudeo

do query

$how_many = num rows returned by query

if $how_many >1 there is a problem

if $how many == 1, do UPDATE else do INSERT

 

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.