scarlson Posted December 1, 2007 Share Posted December 1, 2007 Here is what I am wanting to do but not sure exactly how to. Once a user logs in, they are now sent to a setup page to start entering in their personal information along with details of their items they want to post. What I want is if the user has already created a "ticket" their info will be showing already. If it's their first time there, then all the text area boxes will be blank and they will be able to create their new "ticket" and INSERT that into the database. The users who already have a ticket created can also edit this ticket so a UPDATE would be needed. Anyone have examples or suggestions on how I should go about this? Thanks in advance, Scott Quote Link to comment Share on other sites More sharing options...
revraz Posted December 1, 2007 Share Posted December 1, 2007 When the user Registers, you would want to build their DB row at that time. When they log in, just have a form come up that reads their Row and populates any data that they already have in their record. Provide a update button that UPDATES the DB with the new data. Quote Link to comment Share on other sites More sharing options...
scarlson Posted December 1, 2007 Author Share Posted December 1, 2007 I don't want them to create this ticket when they register because I built in a email verification for them to verify their account. Once verified they can go to the login page to login. Then redirected to this create ticket page that might already have info depending if they are an exisiting user or not. I don't want to create 2 different .php files one for the first time setting up the ticket and another one for editing a ticket, unless I have to. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 1, 2007 Share Posted December 1, 2007 On the page, use their id and query the database for their record. If the query returned a row, put the values into the value="..." parameters in the form. When they submit the form, use their id and query the database for their record. If the query returned a row, they already have a row and you need to perform an UPDATE query. If the query did not return a row, you need to perform an INSERT query. Pretty basic if() {// a row was found, do an UPDATE } else {// no row found, do an INSERT } logic - if(mysql_num_rows($result) > 0) { // They already have a record, use an UPDATE query } else { // They don't have a record, use an INSERT query. } Quote Link to comment 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.