Page 1 of 1

Index Notice

Posted: Mon Apr 12, 2004 5:09 pm
by richie256
I don't know why, but here is the notice I got in my webpage:

Code: Select all

Notice: Undefined index: prenom in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 123

Notice: Undefined index: nom in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 124

Notice: Undefined index: adresse in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 125

Notice: Undefined index: adresse2 in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 126

Notice: Undefined index: ville in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 127

Notice: Undefined index: province in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 128

Notice: Undefined index: pays in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 129

Notice: Undefined index: code_postal in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 130

Notice: Undefined index: no_tel in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 131

Notice: Undefined index: email in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 132

Notice: Undefined index: password in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 133

Notice: Undefined index: password2 in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 134

Notice: Undefined variable: submit in C:\Program Files\Apache Group\Apache2\htdocs\clients.php on line 138
And here is my code... is there any better way to write it? thanks.

Code: Select all

$PARAM = array_merge(
    	        $HTTP_GET_VARS, $HTTP_POST_VARS
        	);
			
			$prenom = $PARAMї'prenom'];
			$nom = $PARAMї'nom'];
			$adresse = $PARAMї'adresse'];
			$adresse2 = $PARAMї'adresse2'];
			$ville = $PARAMї'ville'];
			$province = $PARAMї'province'];
			$pays = $PARAMї'pays'];
			$code_postal = $PARAMї'code_postal'];
			$no_tel = $PARAMї'no_tel'];
			$email = $PARAMї'email'];
			$password = $PARAMї'password'];
			$password2 = $PARAMї'password2'];

Posted: Mon Apr 12, 2004 5:39 pm
by JAM
I cant replicate the issue locally.
$_GET

Variables provided to the script via HTTP GET. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).
$_POST

Variables provided to the script via HTTP POST. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).
Meaning, that you should be able to:

Code: Select all

$PARAM = array_merge(
               $_GET, $_POST
           );
...just as well. If that still wont work, the error is within the script.

Are you trying to send a form where all fields are blank? In that case you need the following:

Code: Select all

$PARAM = array_merge(
               $HTTP_GET_VARS, $HTTP_POST_VARS
           );
         
         if (!empty($PARAM['prenom'])) { $prenom = $PARAM['prenom']; }
         // etc. etc...
...but I prefer using $_POST/$_GET as is seperately.

Good luck, hope it helped.

Posted: Mon Apr 12, 2004 7:23 pm
by richie256
you are right JAM, my variable weren't declared. I must declare them by this way:

Code: Select all

<?php
$PARAM = array_merge(
     $_GET, $_POST
);
			
if (!empty($PARAM['prenom'])) {$prenom = $PARAM['prenom'];} else {$prenom = '';}
if (!empty($PARAM['nom'])) {$nom = $PARAM['nom'];} else {$nom = '';}
if (!empty($PARAM['adresse'])) {$adresse = $PARAM['adresse'];} else {$adresse = '';}
if (!empty($PARAM['adresse2'])) {$adresse2 = $PARAM['adresse2'];} else {$adresse2 = '';}
if (!empty($PARAM['ville'])) {$ville = $PARAM['ville'];} else {$ville = '';}
if (!empty($PARAM['province'])) {$province = $PARAM['province'];} else {$province = '';}
if (!empty($PARAM['pays'])) {$pays = $PARAM['pays'];} else {$pays = '';}
if (!empty($PARAM['code_postal'])) {$code_postal = $PARAM['code_postal'];} else {$code_postal = '';}
if (!empty($PARAM['no_tel'])) {$no_tel = $PARAM['no_tel'];} else {$no_tel = '';}
if (!empty($PARAM['email'])) {$email = $PARAM['email'];} else {$email = '';}
if (!empty($PARAM['password'])) {$password = $PARAM['password'];} else {$password = '';}
if (!empty($PARAM['password2'])) {$password2 = $PARAM['password2'];} else {$password2 = '';}
?>

Posted: Mon Apr 12, 2004 7:25 pm
by andre_c
Maybe there's something that i'm not understanding, why not use $_REQUEST?
(sorry for asking something that doesn't really help )

Posted: Mon Apr 12, 2004 7:30 pm
by markl999
Yeah, $_REQUEST makes more sense, but i'm not even sure what the purpose of the whole code is, why create all those new variables? If $_REQUEST['foo'] exists then i don't see the need to create another temporary variable called $foo, just use $_REQUEST['foo'] *shrug* ;)

Posted: Mon Apr 12, 2004 7:49 pm
by richie256
andre_c wrote:Maybe there's something that i'm not understanding, why not use $_REQUEST?
(sorry for asking something that doesn't really help )
Because I must use there variable in my script... and it can happend that the variable aren't set.

Posted: Mon Apr 12, 2004 7:51 pm
by richie256
I do this way because I do some validation after the post of the form and I use the same php file to do this.