Jump to content

[SOLVED] $_POST command working funky


Derleek

Recommended Posts

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

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

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?

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.