Jump to content

using $_get and/or $_post


seany123

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/156957-using-_get-andor-_post/
Share on other sites

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 )); 

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.

Archived

This topic is now archived and is closed to further replies.

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