364,111 Members | 2089 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Cant write code in button click

Ammu
P: 35
hi
I have a button in my page. I want to write some codes inside that. I use so many methods but shows errors. i have use
Expand|Select|Wrap|Line Numbers
  1. if($_GET['submit']!='')
  2. and
  3. if ($submit)
  4. and
  5. if($_GET['submit']
  6.  
showing errors like
Notice: Undefined index: submit in C:/....
can anybody help to solve this problem?
Jan 27 '12 #1

✓ answered by Dormilich

when you load the page for the first time, you certain have not made a submit, hence the value does not exists and that is the error you get. you need to test, whether the key exists before you can use it.

Expand|Select|Wrap|Line Numbers
  1. if (isset($_GET['submit']))
  2. {
  3.     // there was a submit element
  4. }
note that the submit button is not submitted by every browser (e.g. IE)
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 6,608
when you load the page for the first time, you certain have not made a submit, hence the value does not exists and that is the error you get. you need to test, whether the key exists before you can use it.

Expand|Select|Wrap|Line Numbers
  1. if (isset($_GET['submit']))
  2. {
  3.     // there was a submit element
  4. }
note that the submit button is not submitted by every browser (e.g. IE)
Jan 27 '12 #2

Ammu
P: 35
Thank you Dormilich.My problem is solved.
Jan 28 '12 #3

Post your reply

Help answer this question



Didn't find the answer to your PHP question?

You can also browse similar questions: PHP