NEP -PHP PROGRAMMING

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14

PART B

. . .

 
   
  
      
 14.Develop a PHP program to design a college admission form using MYSQL database.
  
 ---------Page.1: program14.php-------------------------
 
 <!DOCTYPE html>
<html lang="en">
<head>
	<title>GFGC KADUR - NEW ADMISSION </title>
</head>
<body>
	<center>
		<h1>GFGC KADUR - NEW ADMISSION</h1>
		<form action="program14S.php" method="post">
			
<p>
	<label for="firstName">First Name:</label>
	<input type="text" name="first_name" id="firstName">
	</p>

<p>
	<label for="lastName">Last Name:</label>
	<input type="text" name="last_name" id="lastName">
	</p>

<p>
    <label for="Gender">Gender:</label>
	<input type="text" name="gender" id="Gender">
	</p>

<p>
	<label for="Address">Address:</label>
	<input type="text" name="address" id="Address">
		</p>

			
<p>
	<label for="emailAddress">Email Address:</label>
	<input type="text" name="email" id="emailAddress">
		</p>

<p>
     <label for="course">COURSE:</label>  
        <select id=course>
           <option>BCA</option>
            <option>Bcom</option>
            <option>Bsc</option>
            <option>BA</option>
         </select>
            
    	</p>
<p>

	<input type="submit" value="Submit">
</p>
		</form>
	</center>
</body>
</html>


------Page.2=program14S.php----------------------------
 <!DOCTYPE html>
<html>

<head>
	<title>NEW Admission </title>
</head>

<center><h1>Application  is submitted </h1></center>

<body>
	<center>
		< ?php

		// servername => localhost
		// username => root
		// password => empty
		// database name => staff
		$conn = mysqli_connect("localhost", "root", "", "");
		
		// Check connection
		if($conn === false){
			die("ERROR: Could not connect. "
				. mysqli_connect_error());
		}
		
		// Taking all 5 values from the form data(input)
		$first_name = $_REQUEST['first_name'];
		$last_name = $_REQUEST['last_name'];
		$gender = $_REQUEST['gender'];
		$address = $_REQUEST['address'];
		$email = $_REQUEST['email'];
		$course = $_REQUEST['course'];
		// Performing insert query execution
		// here our table name is college
		$sql = "INSERT INTO college VALUES ('$first_name', 
			'$last_name','$gender','$address','$email','$course')";
		
		if(mysqli_query($conn, $sql)){
			echo "<h3>data stored in a database successfully."
				. " Please browse your localhost php my admin"
				. " to view the updated data</h3>"; 

			echo nl2br("\n$first_name\n $last_name\n "
				. "$gender\n $address\n $email");
		} else{
			echo "ERROR: Hush! Sorry $sql. "
				. mysqli_error($conn);
		}
		
		// Close connection
		mysqli_close($conn);
		?>
	</center>
</body>

</html>


</body>
</html>

</body>
</html>