Jim R Posted August 11, 2010 Share Posted August 11, 2010 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). Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/ Share on other sites More sharing options...
litebearer Posted August 11, 2010 Share Posted August 11, 2010 It would help to see (1) database structure and (2) any code you have tried thus far Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098095 Share on other sites More sharing options...
Jim R Posted August 11, 2010 Author Share Posted August 11, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098107 Share on other sites More sharing options...
litebearer Posted August 11, 2010 Share Posted August 11, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098137 Share on other sites More sharing options...
litebearer Posted August 11, 2010 Share Posted August 11, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098140 Share on other sites More sharing options...
Jim R Posted August 11, 2010 Author Share Posted August 11, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098142 Share on other sites More sharing options...
litebearer Posted August 11, 2010 Share Posted August 11, 2010 correct Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098144 Share on other sites More sharing options...
Jim R Posted August 11, 2010 Author Share Posted August 11, 2010 (I was typing my response as you were typing your second one, but at least I'm following your logic.) Is there MySQL/PHP command I should use, or am I basically using IF...THEN statements? Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098146 Share on other sites More sharing options...
litebearer Posted August 11, 2010 Share Posted August 11, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/210440-enter-new-information-into-an-established-database/#findComment-1098182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.