Hello, I've always liked coding and lately I've learned a little but more of it.
Now I also understand sql and db a little more.

My problem is that my register.php file seems to give me a notice.

Notice: Undefined index: op in C:\wamp\www\hacks4all.wapzan.com\registration\register.php on line 11
Notice: Undefined index: op in C:\wamp\www\hacks4all.wapzan.com\registration\register.php on line 55

the code is the following:

    // dbConfig.php is a file that contains your
    // database connection information. This
    // tutorial assumes a connection is made from
    // this existing file.
    include ("dbConfig.php");
    //Input vaildation and the dbase code
    if ( $_GET["op"] == "reg" )
    $bInputFlag = false;
    foreach ( $_POST as $field )
    if ($field == "")
    $bInputFlag = false;
    $bInputFlag = true;
    // If we had problems with the input, exit with error
    if ($bInputFlag == false)
    die( "Problem with your registration info. "
    ."Please go back and try again.");
    // Fields are clear, add user to database
    // Setup query
    $q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
    ."VALUES ('".$_POST["username"]."', "
    ."PASSWORD('".$_POST["password"]."'), "
    // Run query
    $r = mysql_query($q);
    // Make sure query inserted user successfully
    if ( !mysql_insert_id() )
    die("Error: User not added to database.");
    // Redirect to thank you page.
    Header("Location: register.php?op=thanks");
    } // end if
    //The thank you page
    elseif ( $_GET["op"] == "thanks" )
    echo "<h2> Thanks for registering!</h2> ";
    //The web form for input ability
    echo "<form action=\"?op=reg\" method=\"POST\"> \n";
    echo "Username: <input name=\"username\" MAXLENGTH=\"16\"> <br /> \n";
    echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"> <br /> \n";
    echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"> <br /> \n";
    echo "<input type=\"submit\"> \n";
    echo "</form> \n";
    // EOF

For what I see it's something with the "op".
In the code at line 10 it says "Input vaildation and the dbase code" and I don't know what it exactly means. If you could please help me, I would really appreciate it!

Thank you, Emanuel.

The reason you get the notice is, that the $_GET array may not have a key with value 'op'. It wants you to check the value before using it. If you want to get rid of it do something like this:

$op = isset($_GET['op']) ? $_GET['op'] : '';
if ($op == 'reg')
commented: Very fast reply and helpful. Thank you! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.