简体   繁体   中英

Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37

Hey i get this : Notice: Undefined index: in C:\\wamp\\www\\tests\\Joomla\\Website\\index.php on line 37

And my code is this :

<?php 
    $remarks=$_GET['remarks'];

    if ($remarks==null and $remarks=="")
    {
        echo '';
    }
    if ($remarks=='success')
    {
        echo 'Registration Success';
    }
?>

I don't understand why i get this . Please help!

First, you don't say where is the line 37... I ain't a wizard, but I can guess from the error...

Since the error is Undefined index , that must come from the line:

$remarks=$_GET['remarks'];

You should validate that $_GET['remarks'] is not null with isset($_GET['remarks']) before trying to get it's value.


Second, that line does not make any sence, since the $remarks can never be null and "" :

 if ($remarks==null and $remarks=="")


So I would write the code like this:

<?php 
    $remarks = "";
    if ( isset($_GET['remarks']) ) {
        $remarks = $_GET['remarks'];
    }

    if ( $remarks == 'success' ) {
        echo 'Registration Success';
    }
?>  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM