Jump to content

[SOLVED] need help on my update page


pixeltrace

Recommended Posts

hi,

 

i have a simple update page but its seem that its not working.

whenever i click the update button, its just refreshes the page and the content is still the same.

below is my current code

<? 
$id = $_GET['id'];
include '../db_connect.php';

$query = mysql_query("SELECT content_id, category_name, content_value FROM static_contents WHERE content_id= '$id'") or die(mysql_error()); 
$row = mysql_fetch_array( $query );
$content_id = $row["content_id"];
$category_name = $row["category_name"];
$content_value = $row["content_value"];

?>

<html>
<head>
<title>Manymoonshop Static Content Update</title>
<!-- TinyMCE -->
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media",
<!--theme_advanced_buttons1_add_before : "save,newdocument,separator",-->
	theme_advanced_buttons1_add : "fontselect,fontsizeselect",
	theme_advanced_buttons2_add : "forecolor,backcolor",
<!--theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",-->
<!--theme_advanced_buttons3_add_before : "tablecontrols,separator",-->
<!--theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",-->
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	content_css : "example_word.css",
    plugi2n_insertdate_dateFormat : "%Y-%m-%d",
    plugi2n_insertdate_timeFormat : "%H:%M:%S",
	external_link_list_url : "example_link_list.js",
	external_image_list_url : "example_image_list.js",
	media_external_list_url : "example_media_list.js",
	file_browser_callback : "fileBrowserCallBack",
	paste_use_dialog : false,
	theme_advanced_resizing : true,
	theme_advanced_resize_horizontal : false,
	theme_advanced_link_targets : "_something=My somthing;_something2=My somthing2;_something3=My somthing3;",
	paste_auto_cleanup_on_paste : true,
	paste_convert_headers_to_strong : false,
	paste_strip_class_attributes : "all",
	paste_remove_spans : false,
	paste_remove_styles : false		
});

function fileBrowserCallBack(field_name, url, type, win) {
	// This is where you insert your custom filebrowser logic
	alert("Filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);

	// Insert new URL, this would normaly be done in a popup
	win.document.forms[0].elements[field_name].value = "someurl.htm";
}
</script>
<!-- /TinyMCE -->
<style type="text/css">
.heading { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; line-height: 1.5; color: #666666; }
</style>
</head>
<body>
<form name="content" action="<? echo $PHP_SELF; ?>" method="post">
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding:8px" class="heading"><? echo "$category_name";?> : update</td>
  </tr>
  <tr>
    <td> </td>
  </tr>
  <tr>
    <td style="padding:8px"><textarea id="elm1" name="elm1" rows="35" cols="80" style="width: 100%"><? echo "$content_value"; ?></textarea></td>
  </tr>
  <tr>
    <td align="right" style="padding:8px"><input type="submit" name="Submit" value="Update">
  <input type="submit" name="close" value="Close Window" onClick="javascript:window.close();">
  <input type="hidden" value="<? echo "$content_id"; ?>" name="id">
<input type="hidden" value="<? echo "$category_name"; ?>" name="category_name"></td>
  </tr>
</table>
</form>
</body>
</html>
<? 
if ($_POST["submit"] == "Update"){

$content_id = $_POST['id'];
$category_name = $_POST['category_name'];
$content_value = mysql_real_escape_string(stripslashes($_POST['content_value']));

$sql="UPDATE static_contents SET content_value='$content_value' WHERE content_id='$content_id'";
	mysql_query($sql) or die("error:".mysql_error());

   echo "$category_name"."content has been updated<br><a href='javascript:window.close()'>Close Window</a>";
   
   }
   ?>


hope you could help me with this.

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/71168-solved-need-help-on-my-update-page/
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.