|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
heiya, been trying to code a page that execute itself, whereby a user typed in a textarea and when the button execute is press, php script is run. i somehow got it to execute but the value $textQuery is not recognised, i mean it
display errors: Notice: Undefined index: textQuery in ..../index2.php on line 56. please help me out asap. thanks in advance Heres the coding: <td width="504" rowspan="2"> <form name="query" method="post" action="index2.php"> <p>Type Query Here:<br></p><textarea name="textQuery" cols=60 rows=10></textarea> <input name="Clear" type="reset" id="Clear" value="Clear"> <input name="execute" type="submit" id="execute" value="Execute" > </form></td> </tr> <tr><td width="92" rowspan="3"> </td></tr> <tr> <td><p>The Output Result:<br></p> <?php $gg = $_POST['textQuery']; if($gg==null){ echo "hello world"; } else { oraQuery($gg); } ?> </td> </tr> </table> |
|
#2
|
||||
|
||||
|
I want to recommend two things...
[1] try using isset() instead of ==null [2] instead of executing your function, try a simple print statement... both of these will help discover if the problem is with the function, or the variable being set PHP Code:
|
|
#3
|
||||
|
||||
|
I forgot to mention, you might want to use $_SERVER['PHP_SELF'] instead of hardcoding the filename [when you submit to yourself].
PHP Code:
|
|
#4
|
|||
|
|||
|
The problem is that $_POST['textQuery'] is only defined when this script is executed as the result of a form action. The first time you load the page, it's undefined. You should protect that code with something like
Code:
if (_REQUEST['execute'] to make sure you got here as the result of clicking the submit button. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > php forms and itself |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|