[solved] can PHP receive variable outsite 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
unix77
Forum Newbie
Posts: 7
Joined: Tue Jun 07, 2005 6:13 am
Location: south korea

[solved] can PHP receive variable outsite form

Post 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 ?
Last edited by unix77 on Tue Jun 14, 2005 5:21 am, edited 1 time in total.
unix77
Forum Newbie
Posts: 7
Joined: Tue Jun 07, 2005 6:13 am
Location: south korea

Post by unix77 »

I got it, i think it is impossible to send data outside form html
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post 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
Post Reply