Hey guys,

I am trying to figure out a way to update a row in a table for my database by filling out information in an html form. What I am doing is filling out a form with a username and other information. I want to be able to either update that information for that specific user, or if that user does not exist yet in that table, then I just want the new information to be added to the table. Right now I am using this function:

$query ="UPDATE table SET column='someinfo', column='moreinfo' WHERE field='username'";

The update works, but of course only if it can find the user already in the database. I want it to be able to add a new user as well. Any help would be much appreciated. Thanks!

Got it figured out. Thanks to anyone who was attempting to help me. It was as simple as adding another query and a little if else statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.