By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,828 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,828 IT Pros & Developers. It's quick & easy.

reciving post data from form

tolkienarda
100+
P: 316
hi all i am sending data from an html form to an update page but since this is still my first script i don't know this step. i've read some stuff on php.net and echoecho but still can't figure how to get my post data being sent
my form sends:
two textareas
one text input
and two selects

i know i need the $_POST command but how do i get my variables from the new page

thanks for any help
here is the form if you need it
Expand|Select|Wrap|Line Numbers
  1. <form action="update.php" method="post">
  2.     <select>
  3. <?    
  4.     $i=1;
  5.         while ($i<=$row)
  6.         {
  7.             $row2=mysql_fetch_row($result);
  8.             echo '<option value="', $row2[1], '">', $row2[2], '</option>';//outputs the unique login name
  9.             $i++;
  10.         }
  11. ?>
  12.     </select>
  13.  
  14.     <select>
  15. <?
  16.  
  17.         $j=1;
  18.  
  19.         while ($j<=$classrow)
  20.         {
  21.             $row3=mysql_fetch_row($classlst);
  22.             echo '<option value="', $row3[1], '">', $row3[1], '</option>';
  23.             $j++;
  24.         }
  25.  
  26. ?>
  27.     </select>
  28.     <input type="text" maxlength="5" name="grade" id="grade" value="grade">
  29.     <br />
  30.     <textarea name="assignments" rows="15" cols="67" id="assignments">assignments</textarea>
  31.     <br />
  32.     <textarea name="comments" rows="15" cols="67" id="comments">comments</textarea>
  33. <input type="submit">
  34. </form>
  35.  
Jan 17 '07 #1
Share this Question
Share on Google+
2 Replies


ronverdonk
Expert 2.5K+
P: 4,258
First: if you want to send the selects to the receiving form, it will do so but you'll have to give the selects a unique name (name="xxx"), because that name will be an entry in the $_POST array. So in your receiving form you get the submitted values e.g.:[php]<?php
if (isset($_POST['grade']))
$grade = "";
$assignments = "";
$comments = "";
$selbox1 = "";
$selbox2 = "";
if (isset($_POST['grade']))
$grade = strip_tags($_POST['grade']);
if (isset($_POST['assigments']))
$assignments = strip_tags($_POST['assignments']);
if (isset($_POST['comments']))
$comments = strip_tags($_POST['comments']);
if (isset($_POST['selbox1']))
$selbox1 = strip_tags($_POST['selbox1']);
if (isset($_POST['selbox2']))
$selbox2 = strip_tags($_POST['selbox2']);

// now your variables are filled with the POST values
// so you can process them now.
[/php]
Ronald :cool:
Jan 17 '07 #2

tolkienarda
100+
P: 316
thanks
eric
Jan 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.