|
-
May 18th, 2008, 06:48 AM
#1
Thread Starter
Member
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");
-
May 21st, 2008, 07:14 PM
#2
Re: MySQL & PHP
that code should work just fine
My usual boring signature: Something
-
May 21st, 2008, 11:00 PM
#3
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.
-
May 21st, 2008, 11:44 PM
#4
Re: MySQL & PHP
i misread his post. oops
sorry
My usual boring signature: Something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|