Web Analytics Made Easy -
StatCounter HELP!!! Problem with undefined variable.... - CodingForum

Announcement

Collapse
No announcement yet.

HELP!!! Problem with undefined variable....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HELP!!! Problem with undefined variable....

    Hey can about tell me why im getting the following undefined notice for the code straight after:

    "Notice: Undefined index: login in C:\xampp\htdocs\Care2Share\loginC2S.php on line 43"

    PHP Code:
    <?php

    $form 
    "<form action='index.php?login=yes' method='POST'>
     <table>
    <tr>
        <td><input type='text' id='usernamebox' name='user' tabindex='1' value='Username' class='textbox' onfocus='usernamebox_focus();' onblur='usernamebox_blur();'></td>
    </tr> 
    <tr>
        <td><input type='text' id='passwordbox' name='pass' tabindex='2' value='Password' class='textbox' onfocus='passwordbox_focus();' onblur='passwordbox_blur();' /></td>
        <td><input type='submit' name='login' value='login' tabindex='3' class='button'> </td>
    </tr>
    </table>
    </form>"
    ;

    if (
    $_POST['login'])
    {
            
    }

    else
    {
        echo 
    "$form";
    }

    ?>
    I'm quite sure im collecting the text name 'login' from inside the definition of the variable $form. But im still getting that notice in the browser for the part of the code where im attempting to apply $_POST['login'] in the if statement condition.

    Can anyone help? I am new to this so is probably a pretty straight forward solution.

  • #2
    Usually, it appears when your variable is not properly set.

    Change this

    PHP Code:
    if ($_POST['login'])
    {
            
    }

    else
    {
        echo 
    "$form";

    to this

    PHP Code:
    if (isset($_POST['login']))
    {
            
    }

    else
    {
        echo 
    "$form";

    Been a sign maker for 8 years. My business:
    American Made Signs

    Comment


    • #3
      Thanks that works perfectly...

      Comment

      Working...
      X