Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2008, 10:04 AM   PM User | #1
Peuplarchie
Regular Coder

 
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
Peuplarchie is an unknown quantity at this point
Post "Undefined index:" in form.

Good night to you all,

I have a kind of shoutbox, flat file based, which give me an error :
"Undefined index:"

I know what this mean, but I don't see my mistakes can somebody help me ?


PHP Code:

<?php

if ($_POST['nameq'] != "" && $_POST['messageq'] != "")
{
$nom $_POST["nameq"];
$nomcorr substr($nom0, -9);
$messageq $_POST["messageq"];



$File date('Y')."/".date('m')."/".date('d')."/messages.html";
$Handle fopen($File'w+');

$Data "<b class=\"red\">$nom</b>";
$Data.= $messageq;
$Data.= "<br/></br/>";
fwrite($Handle$Data);

fclose($Handle);


}

?>




<form action="" method="post">
<input type="text" name="nameq" value="<? echo $_SESSION['Name'];?>"/>
<?
echo "<select  name=\"COLOUR_CHOICE\" id=\"COLOUR_CHOICE\">";

$colourArray = array("000000""cccc99""FFFFFF""0000FF");
for (
$i 0$i count($colourArray); $i++)
{
    
$selected = ($colourArray[$i] == trim($_POST['COLOUR_CHOICE'])) ? 'selected="selected"' '';
    echo 
'<option value="' $colourArray[$i] . '"' $selected  ' . id="opt' $colourArray[$i] . '">#' $colourArray[$i] . '</option>';
}  
echo 
"</select>";
?>

<textarea name="messageq"></textarea>
<input type="submit" name="Envoyer !!!" value="post"/>
</form>


Thanks!
Have a good one !
Peuplarchie is offline   Reply With Quote
Old 05-19-2008, 10:22 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
It's due to the usage any uninitialised variables somewhere is the page. Check the line number along with the error!
Also see http://in2.php.net/error_reporting , if you really want to suppress this notice.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-19-2008, 11:00 AM   PM User | #3
Peuplarchie
Regular Coder

 
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
Peuplarchie is an unknown quantity at this point
Bingo, I had to use isset :


if (isset($_POST['nameq'])) {


Thanks !
Peuplarchie is offline   Reply With Quote
Old 05-19-2008, 07:49 PM   PM User | #4
aedrin
Senior Coder

 
Join Date: Jan 2007
Posts: 1,648
Thanks: 1
Thanked 58 Times in 54 Posts
aedrin will become famous soon enough
Quote:
Originally Posted by abduraooft View Post
if you really want to suppress this notice.
This is a really bad idea. You don't want to ever suppress warnings/errors.
aedrin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:22 PM.


Advertisement
Log in to turn off these ads.