-
Re: MySQL & PHP
Ok if I wanted to create an update form for a page that has been published to the web already, how would i go about doing it so that when a user clicks on update form, enters values that the values entered can be part of the update action.
can i declare like $textbox1 = textbox1.text
then do like mysql_query("UPDATE `tablename` SET field2='$textbox1' LIMIT 1");
-
Re: MySQL & PHP
that code should work just fine
-
Re: MySQL & PHP
Use the $_GET or $_POST arrays to access form data. For an update form, you should be using POST. Also, ensure that you escape data before inserting it into a SQL query, or your data is exposed to arbitrary attack via SQL injection.
PHP Code:
$value = $_POST['fieldname']
# ...
mysql_query("
UPDATE tablename
SET field2='".mysql_real_escape_string($value)."'
");
The LIMIT clause is usually unnecessary, but you should have some other way of identifying the row you want to update. Usually a primary key is used here.
-
Re: MySQL & PHP
i misread his post. oops :blush:
sorry :wave: