If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Insert into a database table

Being a new one in php I am trying to learn simple login example from the video from "TheProgrammingSchool.com" but this code to insert data in the table named "user_info" in the database "users" is not working. But in his video it seems it is working, may be I am doing something wrong. can anyone looked into the code below.
"user_info" table consists of "user_id","username","password" and "email. Here is the code

In MySQL the character for quoting table/column names is the left quote or back-tick: `
You have a 'normal' quote around them: '
That 'normal' (or straight) quote is only for literal character values, such as you have around the variables in the VALUES() clause.

On a side note, you are inserting the $username and $email values without any sort of escaping, leaving your script open to SQL injection. (The md5() of the password should take care of any issues in that case, though you really should be using at least sha1() with a "salt" for better security.) So....

And while we're at it, the MySQL extension is now officially deprecate in the latest PHP release, so you really should be moving on to either the MySQLi extension, or even the PDO extension (preferably getting all object-oriented with them and making use of prepared statements to take care of SQL injection issues. )

"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation

Thanks for the information and I am really thankful to you for this valuable advise. However at present I could not insert the data in the table "user_info"( having four place naming "user_id", "username", "password", "email" ) in the database "users". Can you test this and check why the data from the form is not inserted into the table (user_info).
Thanks for the reply.