Page 1 of 1

[solved] can PHP receive variable outsite form

Posted: Tue Jun 14, 2005 1:58 am
by unix77
Hi all

I got one PHP + HTML example that make me confuse. I post this code here :


Code: Select all

<html>
   <body>
     <table>
         <tr>
	    <td>Note</td>
            <td>

Code: Select all

<?php
		 print("<textarea rows=\"5\" cols = \"40\"");
		 print("name=\"note\">$note</textarea>");
	       ?>

Code: Select all

&lt;/td&gt;
	  &lt;/tr&gt;
     &lt;/table&gt;
     &lt;form action=&quote;changestar1.php&quote; method=&quote;post&quote;&gt;

Code: Select all

<?php
		print("<input type=\"HIDDEN\" name=\"code\"");
		print("<value=\"$code\">");
	?>

Code: Select all

&lt;input type=&quote;submit&quote; value=&quote;SAVE&quote;&gt;
      &lt;/form&gt;

   &lt;/body
&lt;/html&gt;
It code try to send variable note to changestar1.php, however, can changestar1.php receive data ?

Posted: Tue Jun 14, 2005 2:55 am
by unix77
I got it, i think it is impossible to send data outside form html

Posted: Tue Jun 14, 2005 2:57 am
by thallish
first of all you need to put your textarea inside your form else you can't get that data

furthermore be sure that you have set your variable $code somewhere above your hidden textfield

and this line

Code: Select all

print(&quote;&lt;value=\&quote;$code\&quote;&gt;&quote;);
should be

Code: Select all

print(&quote;value=\&quote;$code\&quote;&gt;&quote;);
after thats done you can grab the data being send from your textara and your hiddden text field by using

Code: Select all

//grab it with theese
$_POST&#1111;'note']
$_POST&#1111;'code']
/thallish