By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

'Notice: Undefined index:' Error

P: 16
I'm getting a error message in php the file is attached.

Notice: Undefined index: textbox in C:\wamp\www\mysite\index.php on line 2

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo $text = $_POST['textbox'];
  3. ?>
  4.  
  5. <form action="index.php" method="post">
  6.     <input type="text" name="textbox">
  7.     <input type="submit" value="Submit">
  8. </form>
Attached Files
File Type: zip index.zip (252 Bytes, 33 views)
Jan 25 '12 #1

✓ answered by Kadir Razu

Yeah, I got your point. If you try to submit an empty text or start processing before submitting line occured. Then processing script will encounter an error.

As a solve, you can check that is a data really posted or not? as bellow :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if($_POST){
  3. echo $text = $_POST['textbox'];
  4. }
  5. ?>

Share this Question
Share on Google+
2 Replies


P: 13
Yeah, I got your point. If you try to submit an empty text or start processing before submitting line occured. Then processing script will encounter an error.

As a solve, you can check that is a data really posted or not? as bellow :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if($_POST){
  3. echo $text = $_POST['textbox'];
  4. }
  5. ?>
Jan 25 '12 #2

P: 16
Thanx for the help Kadir Razu
Jan 26 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.