-1

This is the first page of my website(AssociationAdd.php). When I clicked the 'Add' button, it shows that :
"Notice: Undefined index: T2 in c:\easyphp1-8\www\efiling\associationaddprocess.php on line 19

Notice: Undefined index: T1 in c:\easyphp1-8\www\efiling\associationaddprocess.php on line 20"

<html>
<head>
<meta http-equiv="Content-Language" content="ja">
<title>Index</title>
</head>
<div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">

<body background="E-Filing%20Management%20System%20Picture/Snow.gif">

<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>

	<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<div style="position: absolute; width: 191px; height: 28px; z-index: 2; left: 546px; top: 441px" id="layer4">
	<font color="#FFFFFF"><span lang="en-us">
	
	
	<font size="4" face="Arial Rounded MT Bold">&nbsp;Association Name</font></span></font></div>
<div style="position: absolute; width: 70px; height: 24px; z-index: 1; left: 298px; top: 442px" id="layer3">
	<font size="4" face="Arial Rounded MT Bold"><font color="#FFFFFF"><span lang="en-us">
	
	
	Index</span></font></font></div>
<p align="center"><span lang="zh-cn">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	</span><font color="#FFFFFF"><span lang="en-us">
	
	
	<font face="Arial Rounded MT Bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>
	<font size="4" face="Arial Rounded MT Bold">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></span></font></p>
	<p align="center"><span lang="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
	
<?php	
	
	echo"<form method='POST' action='AssociationAdd.php'>";
	echo"<input type='text' name='T2' size='11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo"<input type='text' name='T1' size='77'></p>";
	echo"<p>&nbsp;<input type='submit' value='   Add   ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo"<input type='reset' value='  Reset  ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo"<input type='submit' value='   Back   ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>";



 	if(isset($_POST["submit"]))
	{
  		$submit = $_POST["submit"];
  		$T1 = $_POST["T1"];
        $T2= $_POST["T2"];
		if($submit=="   Add   ")
		{
			print "<script language ='javascript'>window.location.href='AssociationAddProcess.php?T1=$T1&T2=$T2'</script>";
 		}

		else if($submit=="   Back   ")
		{
   			print "<script language ='javascript'>window.location.href='Association.php'</script>";
 		}
 	}
 	echo"</form>";
?>
</div>
</body>

</html>

This is the second page(AssociationAddProcess.php):

<html>
<head>
<meta http-equiv="Content-Language" content="ja">
<title>Index</title>
</head>
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">

<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>

<?php
   
   $id = $_POST["T2"];
   $an = $_POST["T1"];
   
     if ($id==null||$an==null)
	{
			print"
			<p align='center'>&nbsp;</p>

			<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
  
                      <td><div align='center'><font color='#FF0000' size='5'><p>Please Enter Index and Association Name Completely</p> </font></div></td>
                    		</tr>
                  				</table></td>
              					</tr>
            				</table></td>
        					</tr>
      					</table></td>
  						</tr>
					</table> ";

 				print "<p align='center'>&nbsp;</p>";
 						echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
                                 <CENTER><p>&nbsp;</p><p>&nbsp;
                                        <tr>
                                        <td align='center'><h12>please wait...</h12></td>
                                        </tr>
                                </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";
	}
   
        else
		{
			$connection=mysql_connect("localhost","root","")
			or die("<font color='#FFFFFF'>Could not connect to MySQL</font>".mysql_error());
	
			$selection=mysql_select_db("efiling")
			or die("<font color='#FFFFFF'>Unable to select database.</font>".mysql_error());

			$sql2 = "SELECT * from association Where AssociationName='$an'";
			$result2 = mysql_query($sql2)
      	 	   or die("<font color='#FFFFFF'>SQL select statement failed</font>");
          
			if (mysql_num_rows($result2) < 1) 
			{
				$sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
				$result=mysql_query($sql)
       		    or die("<font color='#FFFFFF'>SQL select statement failed</font>");
          
				if ($result)
   				{
   					print "<script language ='javascript'>window.alert('Added Succesfully!');window.location.href='AssociationAdd.php'</script>";
 				}
			
				else   
				{ 
					die(mysql_error()); 
				}     
			}
			else
			{
				print"<p align='center'>&nbsp;</p>
							<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
              		          <td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
               				     </tr>
         					         </table></td>
        		       				      </tr>
      								      </table></td>
       									 </tr>
     								 </table></td>
 								 </tr>
							</table> ";

 						print "<p align='center'>&nbsp;</p>";
						 echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
                                 <CENTER><p>&nbsp;</p><p>&nbsp;
                                        <tr>
                                        <td align='center'><h12>please wait...</h12></td>
                                        </tr>
                                </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";

			}
		}
?>

</body>
</html>

Anyone can tell me what is the problem and how to solve it?

4
Contributors
14
Replies
15
Views
7 Years
Discussion Span
Last Post by nav33n
-1

Notices are not errors. If you try to use a variable without initializing it, you will get a notice. To disable notices, edit your php.ini and set error_reporting as,

error_reporting = E_ALL & ~E_NOTICE

This will show all the errors except notices.
But, if you want fix these notices, initialize every variable to null or 0 before using it.

0

Notices are not errors. If you try to use a variable without initializing it, you will get a notice. To disable notices, edit your php.ini and set error_reporting as,

This will show all the errors except notices.
But, if you want fix these notices, initialize every variable to null or 0 before using it.

changed already, still same.

-1

What did you change ? php.ini or your script ?
If you are talking bout php.ini, did you restart your server ?

0

What did you change ? php.ini or your script ?
If you are talking bout php.ini, did you restart your server ?

Is that all of the error_reporting need to change to "error_reporting = E_ALL & ~E_NOTICE"?

Just now I didn't restart, now I restart already. It does not have the error already. But it still connect to "Please Enter Index and Association Name Completely" although I typed the index and name.

What does "error_reporting = E_ALL & ~E_NOTICE" means?

Edited by kira4: n/a

0

Hi

If you need the values from first page you should use the session for this implementation.

0

Hi

If you need the values from first page you should use the session for this implementation.

But I don't know how to use session at all. >.<
using normal php cannot POST?

-1

Is that all of the error_reporting need to change to "error_reporting = E_ALL & ~E_NOTICE"?

Just now I didn't restart, now I restart already. It does not have the error already. But it still connect to "Please Enter Index and Association Name Completely" although I typed the index and name.

Since you aren't seeing the notices anymore, you have solved that problem. The other 'problem' you are talking about is a user defined error message. That simply means, you have written the logic wrong. I don't have enough time to go through your code, so I can only comment on it later.

What does "error_reporting = E_ALL & ~E_NOTICE" means?

This simply tells the php parser to report all the errors ~(negating or excluding) notices.

1

Also, it isn't necessary to echo out the forms...It's a lot easier to directly include them outside the PHP tags.
I'd also try to use better variable naming.
Why all the nonbreaking spaces? ( &nbsp; ).
If you REALLY need a space, try using CSS to provide that. ( <div style="width:200px; height:200px; position:relative"></div> )
It's also easier to redirect using head outputs, unless the form processing code isn't at the top of the document. I'd suggest putting the form processing code at the top, so you could simply do a header('Location: myloc.php'); .
You don't have to echo out code from if's, instead just close php like:

<?php if ($submit == true){ ?>
Thanks for you submission!
<?php } else { ?>
There were errors in your form.
<?php } ?>

Or using keywords:

<?php if ($submit == true): ?>
Thanks for you submission!
<?php endif; ?>

Most of this stuff makes the code easier to read, and less prone to blatant errors.

Edited by codejoust: A similey was put in the code... forgot to add icode tags.

0

This problem was solved, thank for your help. :)
But now I am facing another problem, SQL select statement failed. Before that I can connect to database, is that any problem in my coding?

0

Sorry, network slow, causes double reply...

Edited by kira4: n/a

0

This problem was solved, thank for your help. :)
But now I am facing another problem, SQL select statement failed. Before that I can connect to database, is that any problem in my coding?

If you can clean up the code to the previous guidelines, and paste them here, I can take a better look at it.
Regarding the error, the statement looks ok..., however, I would select the database in the connect statement.
Make sure your connect variables are correct (you can echo them out before it connects to check), and the variable order is correct.
Is the connect or the query failing?

0

If you can clean up the code to the previous guidelines, and paste them here, I can take a better look at it.
Regarding the error, the statement looks ok..., however, I would select the database in the connect statement.
Make sure your connect variables are correct (you can echo them out before it connects to check), and the variable order is correct.
Is the connect or the query failing?

This is my "AssociationAdd.php" after solved the POST problem :

<html>
<head>
<title>Index</title>
</head>
<div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">
<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<div style="position: absolute; width: 191px; height: 28px; z-index: 2; left: 546px; top: 441px" id="layer4">
	<font color="#FFFFFF"><span lang="en-us">
		
	<font size="4" face="Arial Rounded MT Bold">&nbsp;Association Name</font></span></font></div>
<div style="position: absolute; width: 70px; height: 24px; z-index: 1; left: 298px; top: 442px" id="layer3">
	<font size="4" face="Arial Rounded MT Bold"><font color="#FFFFFF"><span lang="en-us">
		
	Index</span></font></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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></span></font></p>
	<p align="center"><span lang="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
	
	<form method='POST' action='AssociationAdd.php'>
	<input type='text' name='T2' size='11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type='text' name='T1' size='77'></p>
	<p>&nbsp;<input type='submit' value='   Add   ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type='reset' value='  Reset  ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type='submit' value='   Back   ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>

<?php
	if(isset($_POST["submit"]))
	{
  		$submit = $_POST["submit"];
  		$T2= $_POST["T2"];
  		$T1 = $_POST["T1"];
		if($submit=="   Add   ")
		{
			print "<script language ='javascript'>window.location.href='AssociationAddProcess.php?T2=$T2&T1=$T1'</script>";
		}	

		else if($submit=="   Back   ")
		{
   			print "<script language ='javascript'>window.location.href='Association.php'</script>";
 		}
 	}
?>

</form>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</div>
</body>
</html>

and this is "AssociationAddProcess.php"

<html>
<head>
<title>Index</title>
</head>
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">
<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn">&nbsp;</span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>

<?php
   
    $id = $_GET['T2'];
	$an = $_GET['T1'];

     	if ($id==null||$an==null)
		{
			print"
			<p align='center'>&nbsp;</p>

			<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
                <td><div align='center'><font color='#FF0000' size='5'><p>Please Enter Index and Association Name Completely</p> </font></div></td>
               		</tr>
                 		</table></td>
           					</tr>
            				</table></td>
        					</tr>
      					</table></td>
  						</tr>
					</table> ";

 				print "<p align='center'>&nbsp;</p>";
 						echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
                                 <CENTER><p>&nbsp;</p><p>&nbsp;
                                        <tr>
                                        <td align='center'><h12>please wait...</h12></td>
                                        </tr>
                                </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";
		}
   
        else
		{
			$connection=mysql_connect("localhost","root","")
			or die("<font color='#FFFFFF'>Could not connect to MySQL</font>".mysql_error());
	
			$selection=mysql_select_db("efiling")
			or die("<font color='#FFFFFF'>Unable to select database.</font>".mysql_error());

			$sql2 = "SELECT * from association Where AssociationName='$an'";
			$result2 = mysql_query($sql2)
      	 	   or die("<font color='#FFFFFF'>SQL select statement failed</font>");
          
			if (mysql_num_rows($result2) < 1) 
			{
				$sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
				$result=mysql_query($sql)
       		    or die("<font color='#FFFFFF'>SQL select statement failed</font>");
          
				if ($result)
   				{
   					print "<script language ='javascript'>window.alert('Added Succesfully!');window.location.href='AssociationAdd.php'</script>";
 				}
			
				else   
				{ 
					die(mysql_error()); 
				}     
			}
			
			else
			{
				print"<p align='center'>&nbsp;</p>
							<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
              		          <td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
               				     </tr>
         					         </table></td>
        		       				      </tr>
      								      </table></td>
       									 </tr>
     								 </table></td>
 								 </tr>
							</table> ";

 						print "<p align='center'>&nbsp;</p>";
						 echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
                                 <CENTER><p>&nbsp;</p><p>&nbsp;
                                        <tr>
                                        <td align='center'><h12>please wait...</h12></td>
                                        </tr>
                                </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";
			}
		}
?>

<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>

</body>
</html>

I tested by edit the echo already, the database error is here :

if (mysql_num_rows($result2) < 1) 
			{
				$sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
				$result=mysql_query($sql)
       		    or die("<font color='#FFFFFF'>SQL select statement failed</font>");

I think I don't have wrong spelling, this is print screen of my database :

http://img127.imageshack.us/img127/7750/association.jpg

0

I was solved the problem.
Don't know why I can't use Index as my field in database, after I changed my field name then no problem already. Thanks for helping. :)

-1

I was solved the problem.
Don't know why I can't use Index as my field in database, after I changed my field name then no problem already. Thanks for helping. :)

FYI, index is a mysql reserved keyword. If at all you want to use them, you should use `, like, `index`. I personally don't prefer using reserved keywords.
Here is a list of reserved keywords.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.