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

Link to comment
Share on other sites

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