PHP code to Add Record in the Database

PHP code to Add Record in the Database

Welcome to this code of…… If you have any difficulty regarding this code, please like our page for discussions. Click here to like the page. https://www.facebook.com/Free-Code-Download-934630353410011/

PHP code to Add Record in the Database

PHP code to Add Record in the DatabaseFREE CODE DOWNLOAD

File Name:

addstudent.php

<?
include_once(“checkSession.php”);
include_once(“connect2.php”);
?>
<html>
<head>
<title> PHP Sample Data Entry Form </title>
</head>
<body bgcolor=”#CCCCFF” text=”#330099″>
<form method= “POST” name = “p” action=”addstudent.php”>
<h1 align=”center”><font face=”Verdana”><b>Data Entry Form</b></font></h1>
<table border=”0″ cellspacing=”0″ align=”Center” >
<tr>
<td>
<font face=”Verdana”><b>Student ID: </b></font>
</td>
<td>
<input type=”text” name=”sid” size=”10″ value=”” />
</td>
</tr>
<tr>
<td>
<font face=”Verdana”><b>Name: </b></font>
</td>
<td>
<input type=”text” name=”name” size=”20″ value=”” />
</td>
</tr>
<tr>
<td>
<font face=”Verdana”><b>Course: </b></font>
</td>
<td>
<input type=”text” name=”course” size=”20″ value=”” />
</td>
</tr>
<tr>
<td>
<font face=”Verdana”><b>Year/Section: </b> </font>
</td>
<td>
<input type=”text” name=”yrsec” size=”5″ value=”” />
</td>
</tr>
<tr>
<td colspan=”2″ align=”right”>
<input type=”submit” name =”p” value=”Submit” />
</td>
</tr>
<tr>
<td colspan=”2″ align=”left”>
<a href=”main.php”>Back to Main Page</a>
</td>
</tr>
</table>
</form>
</body>
</html>
<?
$p = $_POST[“p”];

if ($p==”Submit”) {
$sid = $_POST[“sid”];
$name = $_POST[“name”];
$course = $_POST[“course”];
$yrsec = $_POST[“yrsec”];

if( $name==” ” || $course_section ==” ” || $birthdate ==” ” ) {
echo ” Fill out form completely.”;
}
else {
$sql = “INSERT INTO student (StudentID, Name, Course, YrSec)
VALUES (‘$sid’, ‘$name’, ‘$course’, ‘$yrsec’)”;

if(!$q=mysql_query($sql)){
echo mysql_error();
}
else {
echo “<br/><br/><h3 align=\”center\”>Successfully Added</h3>”;
}
}
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *