'Notice: Undefined index:' Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tharindu96
    New Member
    • Jan 2012
    • 16

    'Notice: Undefined index:' Error

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

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

    Code:
    <?php
    echo $text = $_POST['textbox'];
    ?>
    
    <form action="index.php" method="post">
    	<input type="text" name="textbox">
        <input type="submit" value="Submit">
    </form>
    Attached Files
    Last edited by Niheel; Jan 25 '12, 09:45 PM. Reason: much easier if you post your question with all the details, your information was merged
  • Kadir Razu
    New Member
    • Feb 2011
    • 13

    #2
    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 :
    Code:
    <?php
    if($_POST){
    echo $text = $_POST['textbox'];
    }
    ?>
    Last edited by Dormilich; Jan 25 '12, 08:08 PM. Reason: Please use [CODE] [/CODE] tags when posting code.

    Comment

    • tharindu96
      New Member
      • Jan 2012
      • 16

      #3
      Thanx for the help Kadir Razu

      Comment

      Working...