Notice: Undefined index:..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • razvanel442
    New Member
    • May 2010
    • 1

    Notice: Undefined index:..

    Hi all i am new here!
    I take a look on forum but i don't found a the answer for my problem
    ok this is my problem:


    Notice: Undefined index: name in C:\wamp\www\reg ister.php on line 47

    Notice: Undefined index: code in C:\wamp\www\reg ister.php on line 48

    Notice: Undefined index: title in C:\wamp\www\reg ister.php on line 49

    Notice: Undefined index: name in C:\wamp\www\reg ister.php on line 99
    Code:
    Line47:$user = $_GET['name'];
    Line48:$pass = $_GET['code'];
    Line49:$char = $_GET['title'];
    Line99:if ( $_GET['name'] <> "" )
    {
    
     if(file_exists("C:\\Documents and Settings\\User1\\Desktop\\Accounts\\$user.ini"))
     {
    	 
        echo '<span style="font-weight: bold;">Account already in use!</span>';
     }
     else
     {
    	 $handle = fopen ( "C:\\Documents and Settings\\User1\\Desktop\\Accounts\\$user.ini", "a+" );
    	fwrite ( $handle, $data );
    fclose ( $handle );
    
        echo '<span style="font-weight: bold;">Account sccefuly created!</span>';
        echo ' </br> <a href="javascript:history.back()">Back</a>';
       
        exit; 
    
    a alittle mor from line 99 :P 
    Detail: I have this code in same page with form :|
     Form: 
    <form action="register.php" method=GET enctype="multipart" >
          <p><span style="font-weight: bold;">Username:</span><br>
          <input type="Text" name="name" >
          </p>
          
          <p><span style="font-weight: bold;">Password:</span><br>
          <input type="password" name="code" ></p>
                
          <p><span style="font-weight: bold;">CharName:</span><br>
          <input type="text" name="title" ></p>
      <input type="Submit" name="" value="Register"></form>
    Last edited by Atli; May 16 '10, 04:44 PM. Reason: Added [code] tags.
  • phobia
    New Member
    • May 2010
    • 5

    #2
    The notices are issued because you're trying to access indexes not currently set in the $_GET variable. Most likely because the form hasn't been submitted, so you should probably create a check for that, but one way to define a default value for the variables is by using ternary statements:
    Code:
    $user = (isset($_GET['user'])) ? $_GET['user'] : '';
    Here the $user variable will be set to the contents of $_GET['user'] if that is set, otherwise to '' (blank).
    Last edited by phobia; May 16 '10, 02:27 PM. Reason: added quick explanation

    Comment

    • manee1982
      New Member
      • Apr 2010
      • 4

      #3
      Hi , i have a same above proublem. but the proublem of mine it's giving me ablank page.
      i hope u help me too

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Originally posted by manee1982
        Hi , i have a same above proublem. but the proublem of mine it's giving me ablank page.
        i hope u help me too
        When you say a blank page what do you mean? This one recorded some PHP errors, are you saying you have no errors, just a blank page? If so, how do you know your problem is the same? Did you try the solution?

        Comment

        Working...