could you help me with a php form problem?

Ilyakar

New member
hi i have a form that needs to access the db. everything works as it should but it keeps saying edit_btn is underfined as a php error. but the script works... could you take a look a the script for me at tell me whats wrong with it?

<?php

$error_msg = "";
$success_msg = "";
$title = "";
$description = "";
$hyperlink = "";
$episode = "";
$episode = "";
$video = "";

$page = $_SERVER['PHP_SELF'];

$sql = mysql_query("SELECT * FROM extra WHERE page='$page'");

while($row = mysql_fetch_array($sql)){

$title = $row["title"];
$description = $row["description"];
$hyperlink = $row["hyperlink"];
$episode = $row["episode"];
$video = $row["video"];
$image = $row["image"];
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($_POST['edit_btn'] == "edit"){

$description = $_POST['description'];
$title = $_POST['title'];
$hyperlink = $_POST['hyperlink'];
$episode = $_POST['episode'];
$video = $_POST['video'];
$image = $_POST['image'];

// Error handling for missing data
if ((!$description) || (!$title) || (!$hyperlink) || (!$episode) || (!$video) || (!$image)) {
$error_msg = '<font color="#FF0000">ERROR: Please do not make the field(s) blank in that section</font>';
} else {

$sqlUpdate = mysql_query("UPDATE extra SET description='$description', title='$title', episode='$episode', video='$video', image='$image',
hyperlink='$hyperlink' WHERE page='$page'");
if ($sqlUpdate){
$success_msg = '<font color="#009900">Your location data has been updated.</font>';
} else {
$error_msg = '<font color="#FF0000">ERROR: Problems connecting to server, please try again.</font>';
}

}
}
?>

<form action="S01E01.php" enctype="multipart/form-data" method="post" name="form1" id="11" value="11">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="18" colspan="7" align="center"><?php print"$error_msg"?><?php print"$success_msg"?></td>
</tr>
<tr>
<td width="183" height="30" align="center"><input name="video" type="text" id="video" value="<?php print "$video"; ?>" size="30" maxlength="250" /></td>
<td width="132" align="center"><input name="title" type="text" id="title" value="<?php print "$title"; ?>" size="22" maxlength="250" /></td>
<td width="60" align="center"><input name="episode" type="text" id ="episode" value="<?php print "$episode"; ?>" size="10" maxlength="250" /></td>
<td width="72" align="center"><input name="image" type="text" id="image" value="<?php print "$image"; ?>" size="12" maxlength="250" /></td>
<td width="72" align="center"><input name="hyperlink" type="text" id="hyperlink" value="<?php print "$hyperlink"; ?>" size="12" maxlength="250" /></td>
<td width="257" align="center"><textarea name="description" id="description" cols="40" rows="3"><?php print "$description"; ?></textarea></td>
<td width="124" align="center"><input name="edit_btn" type="hidden" value="edit" />
<input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
</table>
</form>
 
Back
Top