Page 1 of 1

hmmmm...Form that doesn't work =) ...

Posted: Wed Jul 13, 2005 8:33 am
by Terriator
Mmm....I have following code which doesn't work. It just keeps giving me the form...did I miss something?..

Code: Select all

<?php
if ($_POST['submit']) {

$content = '$_POST['page']';
mysql_query("UPDATE website SET home = $content WHERE pageID = 1");

}else{
?>

<FORM ACTION="edit_home.php" METHOD="POST">

<p align="center">
<TEXTAREA NAME="page" ROWS="3" cols="20"  NAME="info"></TEXTAREA><br>
<INPUT TYPE="submit"/> </p>
<p align="center"> </p>

</FORM>

<?php
}
?>

Posted: Wed Jul 13, 2005 8:44 am
by shiznatix
<INPUT TYPE="submit"/> needs to be <input type="submit" name="submit"> you gotta name it for it to be $_POST['submit']

Posted: Wed Jul 13, 2005 9:52 am
by Terriator

Code: Select all

<?php
    include("header.php");

//////////////////////////////// Start..

if ($_POST['submit']) {

$content = $_POST['page'];
mysql_query("UPDATE website SET home = $content WHERE pageID = 1");
echo"<center>Your homepage has been updated</center>";

}else{
?>


<p align="center">
<b><br><font size="3"><u>Here you can change the message you see at the page: 'home':</u></font></b> <br><br>
</p>


<FORM ACTION="edit_home.php" METHOD="POST">
<p align="center">
<TEXTAREA NAME="page" ROWS="3" cols="20"  NAME="info"></TEXTAREA><br>
<INPUT TYPE="submit" NAME="submit"> </p>
<p align="center"> </p>
</FORM>

<?php
}
//////////////////////////////// End..

include("footer.php");
 ?>
Here's the whole thing...Still doesn't work ^_^;;

Posted: Wed Jul 13, 2005 9:56 am
by shiznatix
u just hitting enter or you actually clicking the submit button. in IE if you dont click the button and just hit enter it does not send the submit button with the form, it would be much better if you tried

<TEXTAREA NAME="page" ROWS="3" cols="20">//why did you have 2 names for this textarea?

if (false !== isset($_POST['page']))//instead of if($_POST['submit'])

Posted: Wed Jul 13, 2005 10:32 am
by hairyjim
Ah yes....The damn enter key. I had similar problem and I was just racking my brains trying to remember what it was...the 'enter' key!

Well another way that I did was to create a hidden field and checked for that which is similar to the previous suggestion.