seany123 Posted May 5, 2009 Share Posted May 5, 2009 im getting slightly confused... i have this textarea on my page and basically, when the submit button is clicked, i want for the text inside the textarea to be inserted into a database field "notepad". <html> <head> <title>MafiaKillerz</title> <link rel="stylesheet" href="/css/style.css" type="text/css" media="all" /> </head> <body alink="#cc9900" vlink="#cc9900" link="#cc9900"> <div id="holder"> </div> <div id="left_c"><div class="g_content"> <h3 style="text-align: left"> Notepad</h3><div class="g_text"> <form action="notepad.php" method="post"> <BR><textarea name='notes' cols='70' rows='8'></textarea><br /> <br /> <br /> <input type='submit' name='update_notepad' value='Update'> </form> <?php if($_GET['submit']) { $query = $db->execute("update `players` set `notepad`=? where `id`=?", array(, $player->id )); } ?> i dont know if ($_GET['submit']) is the correct way get the info.... its the php part where im getting confused... im not sure how i get the text from the textarea and use it in a query. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 The form method is post, so you should use $_POST and not $_GET. Also, if you're inserting something, why are you using UPDATE? Quote Link to comment Share on other sites More sharing options...
seany123 Posted May 5, 2009 Author Share Posted May 5, 2009 well i thought that because notepad may already have a text in it, you would want to update it with the new text in the textarea. and what would i put in the array part of this query? $query = $db->execute("update `players` set `notepad`=? where `id`=?", array(, $player->id )); Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Well... do you know how to get a POST field submitted through a form? By the way, it doesn't matter what you put in there now because it'll never be executed. Check your if conditional statement. Quote Link to comment Share on other sites More sharing options...
seany123 Posted May 5, 2009 Author Share Posted May 5, 2009 i dont understand. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 The form method is post, so you should use $_POST and not $_GET. Also, if you're inserting something, why are you using UPDATE? Allow me to quote myself. In your form, you set the method to post, right? So why did you use $_GET in your if conditional instead of $_POST? Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted May 5, 2009 Share Posted May 5, 2009 First change to $_POST['update_notepad'] I always like to use the name of the submit button to check against. Then for your DB, you need to INSERT, and if it's already there, then ON DUPLICATE KEY UPDATE... This way if the record isn't there, you INSERT a new one, if it is, you just UPDATE. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.