Index Notice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
richie256
Forum Commoner
Posts: 37
Joined: Mon Oct 13, 2003 8:00 pm
Location: Montréal/Canada

Index Notice

Post 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'];
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
User avatar
richie256
Forum Commoner
Posts: 37
Joined: Mon Oct 13, 2003 8:00 pm
Location: Montréal/Canada

Post 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 = '';}
?>
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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 )
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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* ;)
User avatar
richie256
Forum Commoner
Posts: 37
Joined: Mon Oct 13, 2003 8:00 pm
Location: Montréal/Canada

Post 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.
User avatar
richie256
Forum Commoner
Posts: 37
Joined: Mon Oct 13, 2003 8:00 pm
Location: Montréal/Canada

Post 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.
Post Reply