php 4.3.1 scripts are showing error
Posted: Wed Apr 23, 2003 12:57 am
this script is showing an error
Notice: Undefined index: a in D:\usr\pub\nazo\index.php on line 2
Notice: Undefined index: submit in D:\usr\pub\nazo\index.php on line 3
when i see the output
the script is here
can anyone here tell me why this error is there
<?php
$a = $HTTP_GET_VARS['a'];
$submit=$HTTP_POST_VARS['submit'];
switch ($a)
{
case 'view':
echo "this is the view page";
break;
case 'validate':
if($submit){
$errmsg="";
//below section checks that name feild is empty or not/////////////////////////////////////
if(empty($name))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your name</font><br>";
}
//below section checks that email feild is empty or not/////////////////////////////////////////////
if(empty($email))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your email address</font>";
}
///////////////////////////below section checks that you have enter place or not
if(empty($place))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your place</font>";
}
///////////////////////////below section checks that you have enter message or not
if(empty($message))
{
echo "<br><font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your message</font>";
}
//if every thing is filled////////////////////////////////
if(!empty($name)&&!empty($email)&& !empty($place)&&!empty($message))
{
/////////////////////////////checks for the correct format of the email////////////////////////////////
if(!eregi("^[A-za-z0-9\_-]+@[A-za-z0-9\_-]+.[A-za-z0-9\_-]+.*",$email))
{
$errmsg.="Your email address is not in a correct format";
echo <<< THIS
<font color="red" face="verdana" size="+1">Your email address is not in a correct format</font>
THIS;
}
//////////////////////////////end of email check///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
include 'smile.php';
$HTTP_POST_VARS['message']=$message;
////////////////////////////if error message is empty///////////////////////////////
if(empty($errmsg))
{
$filename="data.txt";
$fptr=fopen($filename,"r");
$content=fread($fptr,filesize ($filename));
fclose($fptr);
////////////////////////////checks whether email already exits or not//////////////////////////////////
if(strstr($content,$email))
{
echo "<br><font color=\"red\" size=\"1\" face=\"verdana\">You have already signed the guest book</font>";
}
else
{
echo "<center><font face=\"verdana\" color=\"red\" size=\"1\">Thank you for signing our Guest book!!<br>";
echo "The following data has been added to the guest book</font>";
echo "<p align=\"center\">".(htmlspecialchars($name))."<br>".$email."<br>".(nl2br($message))."<br>".$place."</p>";
echo "<a href=\"view.php\">view our Guestbook</a></center>";
/////////////////////////////
$fp = fopen('data.txt','a');
if(!$fp) {
echo "Error opening file!";
exit;
}
$line = date("d.F.Y") . "#" . $HTTP_POST_VARS['name'];
$line .= "#" . $HTTP_POST_VARS['email'];
$line .= "#" . ucfirst($HTTP_POST_VARS['message']);
$line .= "#" . ucfirst($HTTP_POST_VARS['place']);
$line = str_replace("\r\n","<BR>",$line);
$line .= "\r\n";
fwrite($fp, $line);
if(!fclose($fp)) {
echo "Error closing file!";
exit;
}
}//end of else
}
//error message is empty do a above
///////////////////////////
}
}
break;
default:
echo <<< END
<html>
<head>
<link rel="stylesheet" href="sign.css" type="text/css">
</head>
</body bgcolor="gainsboro" text="#000000">
<table width=80% align=right cellpadding=0 cellspacing=0 border=0 valign=top height=250>
<tr> <td width=50%>
<form action="index.php?a=validate" method="POST" name="guest">
<br><b>name:</b><br><input type="text" name="name">*
<br><b>E-mail:</b><br><input type="text" name="email">*
<br><b>Place:</b><br><input type="text" name="place">*
<br><b>Message:</b>*<br>
</b><textarea cols="40" rows="10" name=message></textarea><br><br>
<input type="submit" value="sign!" class="button">
<input type="reset" name="reset" class="button">
</form>
</td>
<td height=50% align=center valign=top>
<br><br>
<b>Smileys:</b><br><br>
<script language="JavaScript" src="script.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
function setSmile(str)
{
obj = document.guest.message;
obj.focus();
obj.value = obj.value + str;
}
//-->
</script>
<a href="javascript:setSmile('
')"><img src="img/smile.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/wink.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/cool.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :J ')"><img src="img/curve-smile.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/tongue.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/biggrin.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/frown.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/astonish.gif" width="15" height="15" border="0"/></a>
<br>
<a href="javascript:setSmile(' %) ')"><img src="img/crazy.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :[] ')"><img src="img/fright.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :smoke: ')"><img src="img/smoke.gif" width="21" height="20" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/evil.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
')"><img src="img/apple.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :moo: ')"><img src="img/moo.gif" width="16" height="16" border="0"/></a>
<br><br><a href="index.php?a=view">[View Guestbook]</a>
</td></tr></table>
</body>
</html>
END;
break;
}//end switch
?>
Notice: Undefined index: a in D:\usr\pub\nazo\index.php on line 2
Notice: Undefined index: submit in D:\usr\pub\nazo\index.php on line 3
when i see the output
the script is here
can anyone here tell me why this error is there
<?php
$a = $HTTP_GET_VARS['a'];
$submit=$HTTP_POST_VARS['submit'];
switch ($a)
{
case 'view':
echo "this is the view page";
break;
case 'validate':
if($submit){
$errmsg="";
//below section checks that name feild is empty or not/////////////////////////////////////
if(empty($name))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your name</font><br>";
}
//below section checks that email feild is empty or not/////////////////////////////////////////////
if(empty($email))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your email address</font>";
}
///////////////////////////below section checks that you have enter place or not
if(empty($place))
{
echo "<font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your place</font>";
}
///////////////////////////below section checks that you have enter message or not
if(empty($message))
{
echo "<br><font color=\"red\" size=\"1\" face=\"verdana\">You failed to enter your message</font>";
}
//if every thing is filled////////////////////////////////
if(!empty($name)&&!empty($email)&& !empty($place)&&!empty($message))
{
/////////////////////////////checks for the correct format of the email////////////////////////////////
if(!eregi("^[A-za-z0-9\_-]+@[A-za-z0-9\_-]+.[A-za-z0-9\_-]+.*",$email))
{
$errmsg.="Your email address is not in a correct format";
echo <<< THIS
<font color="red" face="verdana" size="+1">Your email address is not in a correct format</font>
THIS;
}
//////////////////////////////end of email check///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
include 'smile.php';
$HTTP_POST_VARS['message']=$message;
////////////////////////////if error message is empty///////////////////////////////
if(empty($errmsg))
{
$filename="data.txt";
$fptr=fopen($filename,"r");
$content=fread($fptr,filesize ($filename));
fclose($fptr);
////////////////////////////checks whether email already exits or not//////////////////////////////////
if(strstr($content,$email))
{
echo "<br><font color=\"red\" size=\"1\" face=\"verdana\">You have already signed the guest book</font>";
}
else
{
echo "<center><font face=\"verdana\" color=\"red\" size=\"1\">Thank you for signing our Guest book!!<br>";
echo "The following data has been added to the guest book</font>";
echo "<p align=\"center\">".(htmlspecialchars($name))."<br>".$email."<br>".(nl2br($message))."<br>".$place."</p>";
echo "<a href=\"view.php\">view our Guestbook</a></center>";
/////////////////////////////
$fp = fopen('data.txt','a');
if(!$fp) {
echo "Error opening file!";
exit;
}
$line = date("d.F.Y") . "#" . $HTTP_POST_VARS['name'];
$line .= "#" . $HTTP_POST_VARS['email'];
$line .= "#" . ucfirst($HTTP_POST_VARS['message']);
$line .= "#" . ucfirst($HTTP_POST_VARS['place']);
$line = str_replace("\r\n","<BR>",$line);
$line .= "\r\n";
fwrite($fp, $line);
if(!fclose($fp)) {
echo "Error closing file!";
exit;
}
}//end of else
}
//error message is empty do a above
///////////////////////////
}
}
break;
default:
echo <<< END
<html>
<head>
<link rel="stylesheet" href="sign.css" type="text/css">
</head>
</body bgcolor="gainsboro" text="#000000">
<table width=80% align=right cellpadding=0 cellspacing=0 border=0 valign=top height=250>
<tr> <td width=50%>
<form action="index.php?a=validate" method="POST" name="guest">
<br><b>name:</b><br><input type="text" name="name">*
<br><b>E-mail:</b><br><input type="text" name="email">*
<br><b>Place:</b><br><input type="text" name="place">*
<br><b>Message:</b>*<br>
</b><textarea cols="40" rows="10" name=message></textarea><br><br>
<input type="submit" value="sign!" class="button">
<input type="reset" name="reset" class="button">
</form>
</td>
<td height=50% align=center valign=top>
<br><br>
<b>Smileys:</b><br><br>
<script language="JavaScript" src="script.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
function setSmile(str)
{
obj = document.guest.message;
obj.focus();
obj.value = obj.value + str;
}
//-->
</script>
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<a href="javascript:setSmile(' :J ')"><img src="img/curve-smile.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<br>
<a href="javascript:setSmile(' %) ')"><img src="img/crazy.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :[] ')"><img src="img/fright.gif" width="15" height="15" border="0"/></a>
<a href="javascript:setSmile(' :smoke: ')"><img src="img/smoke.gif" width="21" height="20" border="0"/></a>
<a href="javascript:setSmile('
<a href="javascript:setSmile('
<a href="javascript:setSmile(' :moo: ')"><img src="img/moo.gif" width="16" height="16" border="0"/></a>
<br><br><a href="index.php?a=view">[View Guestbook]</a>
</td></tr></table>
</body>
</html>
END;
break;
}//end switch
?>