Click here to Skip to main content
15,791,934 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php
  $link=mysqli_connect("localhost","root","");
  mysqli_select_db($link,"md");
  ?>

<html>
  <head>
     <title>MD</title>
	 <style>
	body{
		background:url('iit.jpg');
		background-repeat:no-repeat;
		background-size:cover;
	}
	</style>
  </head>
     <body>
     <h1>ITI</h1>
	 <form name="form1" action="" method="post">
       <table>
	     <tr>
		   <td>S.no</td>
		   <td><input type="number" name="t1"></td>
		 </tr>
		 <tr>
		   <td>Date</td>
		   <td><input type="text" name="t2"></td>
		 </tr>
		 <tr>
		   <td>StudentName</td>
		   <td><input type="text" name="t3"></td>
		 </tr>
		 <tr>
		   <td>Fess</td>
		   <td><input type="text" name="t4"></td>
		 </tr>
		 <tr>
		   <td>Dep.Fees</td>
		   <td><input type="text" name="t5"></td>
		 </tr>
		 <tr>
		   <td>Due Fees</td>
		   <td><input type="text" name="t6"></td>
		 </tr>
		 <tr>
		 <td colspan="2" align="center"><input type="submit" name="submit1" value="Insert">
		                                <input type="submit" name="submit2" value="Delete">
										<input type="submit" name="submit3" value="Update">
										<input type="submit" name="submit4" value="Display">
										<input type="submit" name="submit5" value="Search"></td>
		 </tr>
	   </table>
       </form>
	   <?php
	        if(isset($_POST["submit1"]))
			{
				mysqli_query($link, "insert into mdd value('$_POST[t1]','$_POST[t2]','$_POST[t3]','$_POST[t4]','$_POST[t5]','$_POST[t6]')");
				
				}
			
            if(isset($_POST["submit2"]))
			{
				mysqli_query($link, "delete from mdd where name='$_POST[t3]'");
				
				}			
			
            if(isset($_POST["submit3"]))
			{
				mysqli_query($link, "update mdd set name='$_POST[t2]'where name='$_POST[t3]'");
				
				}			
			
             if(isset($_POST["submit4"]))
			{
				$res=mysqli_query($link, "select * from mdd" );
				echo"<table border=3 bgcolor=wheat width=70%>";
				echo"<tr>";
					echo"<th>";  echo "S.no";  echo"</th>";
					echo"<th>";  echo "Date";  echo"</th>";
					echo"<th>";  echo "Student Name";  echo"</th>";
					echo"<th>";  echo "Fees";  echo"</th>";
					echo"<th>";  echo "Dep. Fees";  echo"</th>";
					echo"<th>";  echo "Due fees";  echo"</th>";
					echo"</tr>";
				while($row=mysqli_fetch_array($res))
				{
					echo"<tr>";
					echo"<td>";  echo$row["s.no"];  echo"</td>";
					echo"<td>";  echo$row["date"];  echo"</td>";
					echo"<td>";  echo$row["name"];  echo"</td>";
					echo"<td>";  echo$row["fees"];  echo"</td>";
					echo"<td>";  echo$row["dep. fees"]; echo"</td>";
					echo"<td>";  echo$row["due fees"];  echo"</td>";
					echo"</tr>";
				}
				echo"</table>";
				
				}
               
			   if(isset($_POST["submit5"]))
			{
				$res=mysqli_query($link, "select * from mdd where name='$_POST[t1]'" );
				echo"<table border=3 bgcolor=wheat width=70%>";
				echo"<tr>";
					echo"<th>";  echo "S.no";  echo"</th>";
					echo"<th>";  echo "Date";  echo"</th>";
					echo"<th>";  echo "Student Name";  echo"</th>";
					echo"<th>";  echo "Fees";  echo"</th>";
					echo"<th>";  echo "Dep. Fees";  echo"</th>";
					echo"<th>";  echo "Due fees";  echo"</th>";
					echo"</tr>";
				while($row=mysqli_fetch_array($res))
				{
					echo"<tr>";
					echo"<td>";  echo$row["s.no"];  echo"</td>";
					echo"<td>";  echo$row["date"];  echo"</td>";
					echo"<td>";  echo$row["name"];  echo"</td>";
					echo"<td>";  echo$row["fees"];  echo"</td>";
					echo"<td>";  echo$row["dep. fees"]; echo"</td>";
					echo"<td>";  echo$row["due fees"];  echo"</td>";
					echo"</tr>";
				}
				echo"</table>";
				
				}				
				
				
				
	   ?>
	   </body>
</html>


What I have tried:

echo""; echo$row["dep. fees"]; echo"";
echo""; echo$row["due fees"]; echo"";

i am tried
error in this 2 lines
Posted
Updated 31-Dec-17 0:43am
Comments
OriginalGriff 31-Dec-17 3:10am    
And?
What's the error? Any message? When does the error come? What do you do to cause it?
What have you tried to get rid of it?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

PHP
echo"<td>";  echo$row["dep. fees"]; echo"</td>";
echo"<td>";  echo$row["due fees"];  echo"</td>";

Make sure those columns exists in $row

PHP
mysqli_query($link, "insert into mdd value('$_POST[t1]','$_POST[t2]','$_POST[t3]','$_POST[t4]','$_POST[t5]','$_POST[t6]')");
$res=mysqli_query($link, "select * from mdd where name='$_POST[t1]'" );

Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900