Derleek Posted July 24, 2008 Share Posted July 24, 2008 So I am implementing the FCK editor (http://www.fckeditor.net/) and i've successfully made it so i can create and submit a text file to my database. I am now trying to make it so I can open a message saved in the database and load the title/message into the editor. That all works fine. But when I try and edit it everything goes crazy. Basically I have variables set to $title and $message to fill out the given form. When i click submit, the variable $title is no where to be found after the submit button is clicked... and i have no clue why. I don't think it really has anything to do with the editor or even the $_POST function. I've made several scripts using $_POST and i haven't gotten any funky results like this... here is my code: <?php include_once("fckeditor/fckeditor_php5.php") ; include_once("db.php"); dbConnect("massMailer"); $title = $_GET['title']; $msg = "SELECT msg FROM mail WHERE title = '$title'"; echo $msg."<br>"; $result = mysql_query($msg) or die(mysql_error()); while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $message = $row['msg'];} ?> <html> <head> <title>Edit Your Message</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Title: <input type = "text" name = "Title" value = "<?php echo $title; ?>"> <?php $oFCKeditor = new FCKeditor('fck') ; echo "$title!!!"; $oFCKeditor->BasePath = '/MassMailer/fckeditor/' ; $oFCKeditor->Value = $message ; $oFCKeditor->Create() ; ?> <br> <input type="submit" value="Submit" name="SubmitBtn1"> </form> </body> </html> <? if($_POST['SubmitBtn1']) { $newTitle = mysql_escape_string($_POST['Title']); $newMessage = mysql_escape_string(stripslashes( $_POST['fck'] )) ; echo "$title!!!<br>"; $sql = "UPDATE mail SET msg= $newMessage AND title = $newTitle WHERE title = $title)"; echo $sql; mysql_query($sql) or die(mysql_error()); } the echo "$title!!!<br>"; line outputs this '!!!<br>' any idea's why $title gets erased after submission? Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/ Share on other sites More sharing options...
drewbee Posted July 24, 2008 Share Posted July 24, 2008 The variable $title should be coming from the $_GET parameter. There is, however, the variable $newTitle. Did you mean to put echo "$newTitle"; ? Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/#findComment-598905 Share on other sites More sharing options...
Derleek Posted July 24, 2008 Author Share Posted July 24, 2008 no, because i am updating the database where the old title's match. if i do $title=$_GET['$title']? will that work? maybe i don't understand how $_GET works because i tried changing the form to form action="<?php echo $_SERVER['PHP_SELF'];?><? echo '?title2=$title'; ?>" method="request"> so i could use 'get' and 'post', because i think i would need to use both. When i make that change and click submit it just clears everything... Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/#findComment-598909 Share on other sites More sharing options...
cooldude832 Posted July 24, 2008 Share Posted July 24, 2008 GET and POST are generic HTTP ways to send data from Client -> server The data in GET and POST are prepared for you to use via apahce/php in two super global arrays $_GET and $_POST These arrays are populated with the key->value association of the GET/POST variables set. so saying <?php $_GET['title']; ?> only works if the GET variable title was passed (usually accopmlished through a url looking like example.com/index.php?title=Animals Does this clear things up? Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/#findComment-598912 Share on other sites More sharing options...
Derleek Posted July 24, 2008 Author Share Posted July 24, 2008 yes, is there a way to pass a variable with $_GET without using it in the url? just curious. Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/#findComment-598934 Share on other sites More sharing options...
cooldude832 Posted July 24, 2008 Share Posted July 24, 2008 cURL can set post/get vars but the default apache setup usually has it as a variable after a ? in the URL its designed to be visible for caching purposes. Post is designed to be "hidden" for nonchahing purposes Link to comment https://forums.phpfreaks.com/topic/116467-solved-_post-command-working-funky/#findComment-598946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.