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
thallish
Forum Commoner
Posts: 60 Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark
Post
by thallish » Wed Mar 02, 2005 11:45 am
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ї'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ї'profile']);
frameworkBottom();
?>
regards
thallish
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 02, 2005 11:48 am
when the page is first requested, there are no post variables..
isset() may help you.
thallish
Forum Commoner
Posts: 60 Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark
Post
by thallish » Wed Mar 02, 2005 11:53 am
that you'll have to explain.
How will that help me? isn't that just for checking?
regards thallish
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 02, 2005 11:56 am
Code: Select all
$profile = (isset($_POSTї'profile']) ? addslashes($_POSTї'profile']) : '');pretty simple huh?
thallish
Forum Commoner
Posts: 60 Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark
Post
by thallish » Wed Mar 02, 2005 11:58 am
excellent!!!
yup that was pretty simple! thanks a lot!
i never seen that before but i'll sure remember it now
regards thallish
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 02, 2005 12:00 pm
if you want to learn how that works.. search for ternary operator on php.net or here..
thallish
Forum Commoner
Posts: 60 Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark
Post
by thallish » Wed Mar 02, 2005 12:02 pm
I will
regards thallish