Using $_GET with textarea input form?

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
xenoalien
Forum Newbie
Posts: 19
Joined: Fri Apr 04, 2008 12:11 pm
Location: Cyberspace

Using $_GET with textarea input form?

Post by xenoalien »

How do I use $_GET with a textarea input form? I have been able to do it with an input form type='text'...

Here is the first code before the submission.

Code: Select all

 
<?php
 
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("Error Connecting");
mysql_select_db ("censored");
 
//build query
$query = mysql_query("SELECT * FROM SchoolBoysRunEvents where id = 1");
 
$array = mysql_fetch_row($query);
 
$total1 = $array[1];
$total2 = $array[2];
$total3 = $array[3];
$total4 = $array[4];
$total5 = $array[5];
$total6 = $array[6];
 
echo '<form method="post" action="updateit.php" />';
echo '<table width="300" height="132" border="0">';
echo  '<tr>
    <td>School</td>
    <td>100m</td>
    <td>200m</td>
    <td>400m</td>
  </tr>
  <tr>
    <td><textarea name="School" cols="10" rows="5">'.$total1.'</textarea></td>
    <td><textarea name="e100m" cols="20" rows="5">'.$total2.'</textarea></td>
    <td><textarea name="e200m" cols="20" rows="5">'.$total3.'</textarea></td>
    <td><textarea name="e400m" cols="20" rows="5">'.$total4.'</textarea></td>
  </tr>
</table><br><br>';
echo '<table width="300" height="132" border="0">';
echo  '<tr>
    <td>800m</td>
    <td>e110m</td>
  </tr>
  <tr>
    <td><textarea name="e800m" cols="20" rows="5">'.$total5.'</textarea></td>
    <td><textarea name="e110m" cols="20" rows="5">'.$total6.'</textarea></td>
  </tr>
</table>';
echo '<br><br><input type="submit" value="Update" />';
echo '</form>';
 
mysql_close($connection);
 
?>
Here is the code that GETs the info from the textarea input forms and updates a database.

Code: Select all

<?php
$school = $_GET['School'];
$e100m = $_GET['e100m'];
$e200m = $_GET['e200m'];
$e400m = $_GET['e400m'];
$e800m = $_GET['e800m'];
$e110m = $_GET['e110m'];
 
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("Error Connecting");
mysql_select_db ("censored");
 
//build query
$query = mysql_query("INSERT INTO SchoolBoysRunEvents (school, 100, 200, 400, 800, e110m)
VALUES('".$school."', '".$e100m."', '".$e200m."', '".$e400m."', '".$e800m."', '".$e110m."') where id = 1");
 
mysql_close($connection);
 
?>
As you can probably see I am making a form that high schools can use to submit participants for meets using input forms and an update button. When they update it will first show what the data is and then they will change it and update it. Next I will make a login but if I can't get that I'll ask in another topic. Thanks!
User avatar
starram
Forum Commoner
Posts: 58
Joined: Thu Apr 10, 2008 1:27 am
Location: India
Contact:

Re: Using $_GET with textarea input form?

Post by starram »

Use form method =GET

I hope that will solve the issue.
User avatar
starram
Forum Commoner
Posts: 58
Joined: Thu Apr 10, 2008 1:27 am
Location: India
Contact:

Re: Using $_GET with textarea input form?

Post by starram »

U can also use $_REQUEST To access textarea value.

Without changing form method.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Using $_GET with textarea input form?

Post by onion2k »

starram wrote:U can also use $_REQUEST To access textarea value.
But don't, because it's a really bad idea. Always make sure you know exactly where your data is originating from.
Post Reply