Page 1 of 1

Problems with undefined index using a selection box

Posted: Wed Mar 02, 2005 11:45 am
by thallish
Hi I got problems with $_POST and a selection box. I get following error and i can't seem to figure out what can be wrong. Can somebody please help me?

Here's my error message:

Code: Select all

PHP Notice: Undefined index: profile in C:\www\webroot\kompetencesystem\101.tmp on line 24
and here's my code:

Code: Select all

<?php
include("framework.php");

frameworkTop();
?>
<p class="header">Rediger medarbejderprofil</p>
<p>Her er det muligt at redigere en given medarbejderprofil.</p>

<form action="<?php echo $_SERVER&#1111;'PHP_SELF'];?>" method="post">

<p>Vælg hvilken del af profilen du vil ændre: <br />
<select name="profile">
	<option value="person">Personoplysninger</option>
	<option value="uddannelse">Uddannelse</option>
	<option value="teknisk">Teknisk erfaring</option>
	<option value="projekt">Projekt erfaring</option>
</select>

<input type="submit" value="Vælg" />
</p>
</form>

<?php
$profile = addslashes($_POST&#1111;'profile']);
 
 
frameworkBottom(); 
 
    
?>
regards
thallish

Posted: Wed Mar 02, 2005 11:48 am
by feyd
when the page is first requested, there are no post variables.. isset() may help you.

Posted: Wed Mar 02, 2005 11:53 am
by thallish
that you'll have to explain. :oops: How will that help me? isn't that just for checking?

regards thallish

Posted: Wed Mar 02, 2005 11:56 am
by feyd

Code: Select all

$profile = (isset($_POST&#1111;'profile']) ? addslashes($_POST&#1111;'profile']) : '');
pretty simple huh? :)

Posted: Wed Mar 02, 2005 11:58 am
by thallish
excellent!!!

yup that was pretty simple! thanks a lot!

i never seen that before but i'll sure remember it now :wink:

regards thallish

Posted: Wed Mar 02, 2005 12:00 pm
by feyd
if you want to learn how that works.. search for ternary operator on php.net or here..

Posted: Wed Mar 02, 2005 12:02 pm
by thallish
I will

regards thallish

:)