Re: form post question

From: Date: Thu, 28 Oct 2010 15:40:14 +0000
Subject: Re: form post question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-309134@lists.php.net to get a copy of this message
Bastien Koert wrote:
On Thu, Oct 28, 2010 at 10:12 AM, Jack <JackListMail@gmail.com> wrote:
I have a form which has the following: ( quick clip ) <form id="form1" name="form1" method="post" action="http://www.abc.com/processing/process_form.php" onSubmit="return preSubmit();">
    <label>
               <input name="area_interest" type="checkbox" id="field13"
value="Peer Guide" />
               Peer Guide</label>
             <br />
             <label>
<input type="submit" value="Submit" /> When the form runs process_form.php it emails the content and has several other fields from the form, but I have some fields like the one above that don't show up in the result. The script that builds the message looks like the below $temp_message .= "Area(s) of Interest: ". $_POST['area_interest'] ."\n"; Is there anything obvious that I am missing? Is there a way for me to show all the fields from the form, and their field names which are received by process_form? Thanks! Jack
Check boxes (assuming you have more than one in the set) are generally coming in as an array. You can see this by running this echo "<pre>"; print_r($_POST); echo "</pre>"; to see the entire post array
+1 for Bastien; print_r() and var_dump() are the keys to debugging. See http://www.phpbuilder.com/board/showthread.php?s=&threadid=10240608 for a decent overview of same. And I guess you could reinvent the wheel, or actually process your POSTed data, with foreach(): // Roll your own print_r() foreach ($_POST as $p => $q) {
      echo $p. "-".$q. "<br />";
} // Or do_something_useful() foreach ($_POST as $p => $q) {
      do_something_useful($p,$q);
} HTH, KDK

« previous php.general (#309134) next »