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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

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

Post 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
}
?>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

<INPUT TYPE="submit"/> needs to be <input type="submit" name="submit"> you gotta name it for it to be $_POST['submit']
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Post 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 ^_^;;
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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'])
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

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