Jump to content

Why doesn't this script work?


dezkit

Recommended Posts

I have 2 problems:

1. I don't see what I have in the database echo'd in the textarea

2. When I submit the form, the database won't get updated.

 

<?php
if($_POST["action"]=="true"){
	$tbl_name="site";
	$edit=$_POST["edit"];
	$description=$_POST["description"];
	$sql="UPDATE $tbl_name SET field='$field', description='$description";
	$result=mysql_query($sql);
	if($result){
		echo "The $field page has been saved.";
		echo "<br>";
		echo "<a href='./admin'>Back to admin page</a> <a href='./$field'>View $edit page</a>";
	} else {
	echo "ERROR";
	}
	mysql_close();
} else {
	$field=$_GET["field"];
	$sql="SELECT * FROM $tbl_name WHERE field='$field'";
	$result=mysql_query($sql);
	while($rows=mysql_fetch_array($result)){
		echo '<form name="form" method="post" action="admin.php?edit='.$_GET["field"].'&action=true">';
		echo '<textarea rows="10" cols="70" name="description" value="'.$rows["description"].'"></textarea>';
		echo '<input type="submit" name="submit" value="submit"></form>';
	}
}?>

 

Thanks guys. :)

Link to comment
https://forums.phpfreaks.com/topic/147457-why-doesnt-this-script-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.