Hey there, it has to be said that I am a complete novice in PHP, I know this is a common error and has probably been covered to some degree already - but my head really does hurt - so I couldn't stand trawling through anymore forums hunting for the right answer. Anyway - here goes.
The page I'm having trouble with is a simple edit row type form, which brings up the specific row content specified by the id(albumNumber) passed from the previous page, select.php. The page allows the user to edit, and then update the row displayed.
The full error message...
Notice: Undefined index: submit in /home/fhlinux162/g/greatestalbumse ver.com/user/htdocs/php/update.php on line 12
The full php - taken and adapted from a tutorial I found...
[code=php]
<?
// Connect database
mysql_connect(" ","","");
//select which database you want to edit
mysql_select_db ("");
// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
if($_POST['submit'])
{
// Get parameters from form.
$albumNumber=$_ POST['albumNumber'];
$artistName=$_P OST['artistName'];
$albumName=$_PO ST['albumName'];
$albumInfo=$_PO ST['albumInfo'];
$albumReview=$_ POST['albumReview'];
// Do update statement.
mysql_query("UP DATE Albums SET artistName='$ar tistName', albumName='$alb umName', albumInfo='$alb umInfo', albumReview='$a lbumReview' WHERE albumNumber='$a lbumNumber'");
// Re-direct this page to select.php.
echo "Query Finished";
header("locatio n:select.php");
}
// ************* End update part *************
// *** Select data to show on text fields in form. ***
// Get id parameter (GET method) from select.php
$albumNumber=$_ GET['albumNumber'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_q uery("select * from Albums where albumNumber='$a lbumNumber'");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetc h_assoc($result );
// Close database connection.
mysql_close();
?>
<!-- END OF PHP CODES AND START HTML TAGS -->
<html>
<body>
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action="update. php">
<p>albumName : <br>
<input name="albumName " type="text" id="albumName" value="<? echo $row['albumName']; ?>" size="40"/>
<br />
artistName :<br>
<input name="artistNam e" type="text" id="artistName " value="<? echo $row['artistName']; ?>" size="40"/>
<br />
albumInfo : <br>
<textarea name="albumInfo " cols="40" rows="4" id="albumInfo"> <? echo $row['albumInfo']; ?></textarea>
<br />
albumReview :<br>
<textarea name="albumRevi ew" cols="40" rows="10" id="albumReview "><? echo $row['albumReview']; ?></textarea>
<br />
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
[/code]
Any help would be much appreciated. The line if($_POST['submit']) work perfectly well in another scripts which adds new rows to the database.
Thanks in advance.
The page I'm having trouble with is a simple edit row type form, which brings up the specific row content specified by the id(albumNumber) passed from the previous page, select.php. The page allows the user to edit, and then update the row displayed.
The full error message...
Notice: Undefined index: submit in /home/fhlinux162/g/greatestalbumse ver.com/user/htdocs/php/update.php on line 12
The full php - taken and adapted from a tutorial I found...
[code=php]
<?
// Connect database
mysql_connect(" ","","");
//select which database you want to edit
mysql_select_db ("");
// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
if($_POST['submit'])
{
// Get parameters from form.
$albumNumber=$_ POST['albumNumber'];
$artistName=$_P OST['artistName'];
$albumName=$_PO ST['albumName'];
$albumInfo=$_PO ST['albumInfo'];
$albumReview=$_ POST['albumReview'];
// Do update statement.
mysql_query("UP DATE Albums SET artistName='$ar tistName', albumName='$alb umName', albumInfo='$alb umInfo', albumReview='$a lbumReview' WHERE albumNumber='$a lbumNumber'");
// Re-direct this page to select.php.
echo "Query Finished";
header("locatio n:select.php");
}
// ************* End update part *************
// *** Select data to show on text fields in form. ***
// Get id parameter (GET method) from select.php
$albumNumber=$_ GET['albumNumber'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_q uery("select * from Albums where albumNumber='$a lbumNumber'");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetc h_assoc($result );
// Close database connection.
mysql_close();
?>
<!-- END OF PHP CODES AND START HTML TAGS -->
<html>
<body>
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action="update. php">
<p>albumName : <br>
<input name="albumName " type="text" id="albumName" value="<? echo $row['albumName']; ?>" size="40"/>
<br />
artistName :<br>
<input name="artistNam e" type="text" id="artistName " value="<? echo $row['artistName']; ?>" size="40"/>
<br />
albumInfo : <br>
<textarea name="albumInfo " cols="40" rows="4" id="albumInfo"> <? echo $row['albumInfo']; ?></textarea>
<br />
albumReview :<br>
<textarea name="albumRevi ew" cols="40" rows="10" id="albumReview "><? echo $row['albumReview']; ?></textarea>
<br />
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
[/code]
Any help would be much appreciated. The line if($_POST['submit']) work perfectly well in another scripts which adds new rows to the database.
Thanks in advance.
Comment