Update database form

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

Update database form

Post by mesz »

I am trying to create a form to update a record.
The column I'm updating from my table is called rej_acc.

I thought that if I entered the id of a row to be updated I could just update a NULL value with accepted.

However this script is crap!
Could someone give me some pointers where I should satrt again.

Code: Select all

<?php
<table width="200" cellpadding="0" cellspacing="0" border="0">
<tr align="center" valign="top">
<td align="left" colspan="1" rowspan="1" bgcolor="#FF69B4">


<form method="post" action="this.php">
id no.:
<br>
<INPUT TYPE='TEXT' NAME='id' VALUE='id' size=60>
<br>
<INPUT TYPE="submit" name="submit" value="submit">
</form>
</td></tr></table>

<?
$id=$_POST['id'];
$rej_acc=$_POST['rej_acc'];
$db="unitedartcity_co_uk_-_db";
$link = mysql_connect("localhost","","");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Select Error: ".mysql_error());
$result=mysql_query("UPDATE tablename SET rej_acc='accepted' WHERE id='$id';
mysql_close($link);
print "updated\n";
?>
?>
Post Reply