Robię właśnie prosty system newsów na stronkę. Mój problem polega na tym że za każdym razem jak z menu wybiorę dodaj newsa to automatycznie do bazy dodaje się pole "autor" i data dodania i nie wiem dla czego, np odświeżę sobie zakładkę dodaj to 5 razy do razy automatycznie doda mi się do pola autor pięć rekordów o wartość "autora" a do pola data pięć rekordów "data bieżąca".
dodaj.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="elrte/js/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script> <script src="elrte/js/jquery-ui-1.8.7.custom.min.js" type="text/javascript" charset="utf-8"></script> <link rel="stylesheet" href="elrte/css/smoothness/jquery-ui-1.8.7.custom.css" type="text/css" media="screen" charset="utf-8"> <!-- elRTE --> <script src="elrte/js/elrte.min.js" type="text/javascript" charset="utf-8"></script> <link rel="stylesheet" href="elrte/css/elrte.min.css" type="text/css" media="screen" charset="utf-8"> <!-- elFinder --> <link rel="stylesheet" href="elrte/css/elfinder.css" type="text/css" media="screen" charset="utf-8" /> <script src="elrte/js/elfinder.full.js" type="text/javascript" charset="utf-8"></script> <script src="elrte/js/i18n/elrte.pl.js" type="text/javascript" charset="utf-8"></script> <script src="elrte/js/i18n/elfinder.pl.js" type="text/javascript" charset="utf-8"></script> <!-- elRTE and elFinder translation messages --> <!--<script src="js/i18n/elrte.ru.js" type="text/javascript" charset="utf-8"></script> <script src="js/i18n/elfinder.ru.js" type="text/javascript" charset="utf-8"></script>--> <script type="text/javascript" charset="utf-8"> // elRTE with elFinder on a textarea $().ready(function() { var opts = { cssClass : 'el-rte', lang : 'pl', // Set your language allowSource : 1, height : 450, toolbar : 'maxi', // 'tiny', 'compact', 'normal', 'complete', 'maxi', or 'custom' (see advanced documentation for 'custom') cssfiles : ['elrte/css/elrte-inner.css'], fmAllow : 1, fmOpen : function(callback) { $('<div id="myelfinder" />').elfinder({ url : 'elrte/connectors/php/connector.php', places : '', lang : 'pl', //Set your language dialog : { width : 900, modal : true, title : 'Files' }, // Open in dialog window closeOnEditorCallback : true, // Close after file select editorCallback : callback // Pass callback to file manager }) } } $('#editor').elrte(opts); // Text field with elFinder var opt = { url : 'elrte/connectors/php/connector.php', places : '', lang : 'pl', editorCallback : function(url) {document.getElementById('field').value=url;}, // The id of the field we want elfinder to return a value to. closeOnEditorCallback : true, docked : false, dialog : { title : 'File Manager', height: 500 }, } $('#open').click(function() { // The id of the button that opens elfinder $('#finder').elfinder(opt) // The id of the div that elfinder will open in $('#finder').elfinder($(this).attr('id')); // It also has to be entered here. }) // Second text field with elFinder var opt2 = { //Must change variable name url : 'elrte/connectors/php/connector.php', places : '', lang : 'pl', editorCallback : function(url) {document.getElementById('field2').value=url;}, //Must change the text field id closeOnEditorCallback : true, docked : false, dialog : { title : 'File Manager', height: 500 }, } $('#open2').click(function() { //Must change the button id $('#finder2').elfinder(opt2) //Must update the div id $('#finder2').elfinder($(this).attr('id')); //Must update the div id }) }) </script> </head> <body> <?php include("polacz.php"); $query = mysql_query("insert into news values('','".$_POST['tytul']."',now(),'".$_POST['autor']."','".$_POST['tresc']."')"); ?> <form action="" method="post"> Tytuł(maksymalnie 100 znaków): <input type="text" name="tytul"> <br/>Autor(maksymalnie 30 znaków) <input type="text" name="autor"> <br/>Treść <textarea id="editor" name="tresc"></textarea> <br/><input type="submit" value="Dodaj"></form> </body> </html>