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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.