0% found this document useful (0 votes)
23 views

PHP Join Coding

The document contains PHP code for a student registration form that inserts user data into a database table. It includes form fields for collecting and validating user input which is then inserted into the student table if valid. A separate file connects to the database and another file retrieves and displays the stored student records in a table.

Uploaded by

royal01818
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

PHP Join Coding

The document contains PHP code for a student registration form that inserts user data into a database table. It includes form fields for collecting and validating user input which is then inserted into the student table if valid. A separate file connects to the database and another file retrieves and displays the stored student records in a table.

Uploaded by

royal01818
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Form.

php

============================
<?php
include("connection.php");
error_reporting(0);
?>
<html>
<body>

<form action="form.php" method="get">


<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value=""><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value=""><br>
<label for="fatname">Father name:</label><br>
<input type="text" id="fatname" name="fatname" value=""><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" value=""><br>
<label for="pass">Paasword:</label><br>
<input type="password" id="pass" name="pass" value=""><br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
if ($_GET['submit'])
{
$fn=$_GET['fname'];
$ln=$_GET['lname'];
$fat=$_GET['fatname'];
$em=$_GET['email'];
$ps=$_GET['pass'];
if($fn!="" && $ln!="" && $fat!="" && $em!="" && $ps!="" )
{
$query="INSERT INTO STUDENT VALUES('$fn','$ln','$fat','$em','$ps')";
$data=mysqli_query($conn,$query);
if($data)
{
echo "Data Inserted into Database successfully..." ;
}
}
else
{
echo "All Fields are required";
}
}
// echo $rn;
// echo $sn;
// echo $cl;

?>

</body>
</html>

=================================================================
Connection.php

==================
<?php
$servername="localhost";
$username="root"; $password="";
$dbname="school";
$conn=mysqli_connect($servername,$username,$password,$dbname); if($conn)
{
echo "";
}
else
{
echo "Connection Failed";
die("connection failed because".mysqli_connect_error());
}
?>

====================================

display.php

<html>
<style>
td{
padding:10px
}
</style>

<?php
include("connection.php");
error_reporting(0);
$query="select * from student";
$data= mysqli_query($conn,$query);
$total=mysqli_num_rows($data);
if($total!=0)
{
?>
<table border="1" cellspacing="5">
<tr>
<th>Firstname</th>
<th>LastName</th>
<th>FatherName</th>
<th>Email</th>
<th>Password</th>
<th colspan="2">Opeartion</th>
</tr>
<?php
while($result=mysqli_fetch_assoc($data))
{
echo "
<tr>
<td>".$result['fname']."</td>
<td>".$result['lname']."</td>
<td>".$result['fatname']."</td>
<td>".$result['email']."</td>
<td>".$result['pass']."</td>
<td>Edit</td>
<td>Delete</td>

</tr>";
}
}
else{

echo "No Record Found";


}
?>
</table>

You might also like