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
Terriator
Forum Commoner
Posts: 60 Joined: Mon Jul 04, 2005 12:46 pm
Post
by Terriator » Wed Jul 13, 2005 8:33 am
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
}
?>
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jul 13, 2005 8:44 am
<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 » Wed Jul 13, 2005 9:52 am
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 ^_^;;
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jul 13, 2005 9:56 am
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 » Wed Jul 13, 2005 10:32 am
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.