PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 27th, 2005, 03:53 PM
confirm045 confirm045 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 28 confirm045 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 54 sec
Reputation Power: 0
Unhappy php forms and itself

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">&nbsp;</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>

Reply With Quote
  #2  
Old January 28th, 2005, 09:43 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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:
<?php
if(!isset($_POST['textQuery'])) {
    echo 
"not set"
} else {
    echo 
"is set to ".$_POST['textQuery'];
    
// oraQuery($_POST['textQuery']); 
}
?>

Reply With Quote
  #3  
Old January 28th, 2005, 09:47 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I forgot to mention, you might want to use $_SERVER['PHP_SELF'] instead of hardcoding the filename [when you submit to yourself].

PHP Code:
<form name="query" method="post" action="<?=$_SERVER['PHP_SELF'];?>"

Reply With Quote
  #4  
Old January 31st, 2005, 11:26 PM
mahasamatman mahasamatman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 mahasamatman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 54 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > php forms and itself


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT