I have a submit button on the page submitting and it comes back blank and does not update , the echo is also blank.
<?
if (isset($_POST['submit'])) {
$newtext = mysql_real_escape_string($_POST['text']);
$doTextEdit = "UPDATE `$database_main`.`texts` SET `texts`.`text` = '$newtext' WHERE `texts`.`id` = '$sid' LIMIT 1" or die(mysql_error());
$retval = mysql_query( $doArtistEdit, $main );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
header("Location: ".$_SERVER['HTTP_REFERER']);
}
?>
This is in the form code
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="$ID" method="post">
Song Name : <input type="text" name="title" value="<?php echo $row_song['title']; ?>"> by Artist Name :<input type="text" name="artist" value="<?php echo $row_artist['artist']; ?>"><br><?php echo $sid; ?><?php echo $database_main; ?><?php echo $doTextEdit; ?>
Lyrics :<br><textarea name="text" cols="72" rows="20"><?php echo str_replace("\n","\n",$row_Recordset1['text']); ?></textarea><br>
<input type="submit" name="editlyrics" value="Edit"></form>
You are checking if
$_POST['submit']is set –But your submit button name is
editlyrics, so it should be –Add a hidden input inside your form –
And now your code would be something like-
Note that you should not be writing code using the outdated
mysql_functions, and learn eithermysqliorPDO– php.net/manual/en/mysqlinfo.api.choosing.php