<?php
$servername= "localhost";
$username="root";
$password="";
$database="mnexam";

$con = mysqli_connect($servername,$username,$password,$database);

if(!$con)
{
die("connection failed : " .mysqli_connect_error());
}
?>

<!DOCTYPE html>
<html>
<head>
<title>insert</title>
</head>
<body>
<div class="row text-center">
<div class="container">
<h1>Insert DATA</h1>
<form action="index.php" method="post">
<input type="text" name="firstname" placeholder="firstname"><br><br>
<input type="text" name="lastname" placeholder="lastname"><br><br>
<input type="email" name="email" placeholder="email"><br><br>
<input type="text" name="number" placeholder="number"><br><br>
<input type="text" name="address" placeholder="address"><br><br>
<input type="submit" name="submit" value="insert"><br><br>
</form>
<button><a href="show.php">Show data</a></button>
</div>
</div>
</body>
</html>
<?php
error_reporting(0);
include 'connection.php';
if (isset($_POST['submit'])) {
$id= $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$number = $_POST['number'];
$address = $_POST['address'];
$sql = "INSERT INTO mnexam (firstname, lastname, number, address,email) VALUES ('$firstname', '$lastname', '$number', '$address', '$email')";
$data=mysqli_query($con,$sql);
if($data)
{
echo "record inserted...";
}
else
{
echo "Error: Something Wrong....";
}
}
?>

<!DOCTYPE html>
<html>
<head>
<title>show table</title>
<style>
th, td
{ padding: 15px; }
</style>
</head>
<body>
<?php
include ('connection.php');

$sql ="select * from mnexam";

$data =mysqli_query($con,$sql);
$total=mysqli_num_rows($data);
if ($total=mysqli_num_rows($data))
{
echo "<table border='2'>";
echo "<tr>";
echo "<th>Id</th>";
echo "<th>Firstname</th>";
echo "<th>Lastname</th>";
echo "<th>Email</th>";
echo "<th>Number</th>";
echo "<th>Address</th>";
echo "<th>Delete</th>";
echo "<th>Update</th>";
echo "</tr>";

⎗
✓
while($result= mysqli_fetch_array($data)) 
{
    echo "<tr>
            <td>".$result['id']."</td>
            <td>".$result['firstname']."</td>
            <td>".$result['lastname']."</td>
            <td>".$result['email']."</td>
            <td>".$result['number']."</td>
            <td>".$result['address']."</td>
            <td><a href='update.php?id=$result[id] & firstname=$result[firstname] & lastname=$result[lastname] & email=$result[email] & number=$result[number] & address=$result[address]'> Update </a></td>
            <td><a href='delete.php?id=$result[id] '> Delete </a></td>
        </tr>";
}

}
else
{
echo "No record found....";
}
?>
</table>
<a href="index.php">HOME</a>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>update</title>
</head>
<body>
<form action="" method="get">
<input type="text" name="id" placeholder="id" value="<?php echo $_GET['id']; ?>"><br><br>
<input type="text" name="firstname" placeholder="firstname" value="<?php echo $_GET['firstname']; ?>"><br><br>
<input type="text" name="lastname" placeholder="lastname" value="<?php echo $_GET['lastname']; ?>" ><br><br>
<input type="email" name="email" placeholder="email" value="<?php echo $_GET['email']; ?>"><br><br>
<input type="text" name="number" placeholder="number" value="<?php echo $_GET['number']; ?>"><br><br>
<input type="text" name="address" placeholder="address" value="<?php echo $_GET['address']; ?>"><br><br>
<input type="submit" name="submit" value="update">
</form>
<?php
error_reporting(0);
include ('connection.php');
if ($_GET['submit'])
{
$id = $_GET['id'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$email = $_GET['email'];
$number = $_GET['number'];
$address = $_GET['address'];
$sql="UPDATE mnexam SET firstname='$firstname' , lastname='$lastname', email='$email' , number='$number', address='$address' WHERE id='$id'";
$data=mysqli_query($con, $sql);
if ($data)
{
//echo "record update";
header('location:show.php');
}
else{
echo "ERROR:SOMTHING WRONG FOR UPDATE RECORD....";
}
}
else
{
echo "<H2>Click on button to UPDATE the change</H2>";
}
?>
</body>
</html>

<?php
include ('connection.php');
$id = $_GET['id'];
$sql ="DELETE FROM mnexam WHERE id='$id'";
$data = mysqli_query($con,$sql);
if ($data)
{
echo "Record deleted.....";
header('location:show.php');
}
else
{
echo "error";
}
?>

Imports System.Data.OleDb
Partial Class Default2
Inherits System.Web.UI.Page
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\aspn.mdb")

⎗
✓
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnissue.Click
    Try
        Dim str As String
        Dim ans As Integer

        str = "Insert into asps values(" & txtcustid.Text & "," & txtproid.Text & ",'" & txtcustname.Text & "' ,'" & txtproname.Text & "','" & txtissudate.Text & "')"
        cn.Open()

        Dim cmd As New OleDbCommand(str, cn)
        ans = cmd.ExecuteNonQuery

        MsgBox("record inserted successfully :" & ans)
        GridView1.DataBind()
        cn.Close()

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub



Protected Sub btnupdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupdate.Click
    Try
        cn.Open()
        Dim str As String
        Dim ans As Integer
        str = "Update asps set proid=" & txtproid.Text & ", ctnm='" & txtcustname.Text & "', pronm='" & txtproname.Text & "', issuedate ='" & txtissudate.Text & "' where ctid=" & txtcustid.Text & ""

        Dim cmd As New OleDbCommand(str, cn)
        ans = cmd.ExecuteNonQuery

        MsgBox("record updated successfully :" & ans)
        GridView1.DataBind()
        cn.Close()

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Protected Sub btndelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndelete.Click
    Try
        cn.Open()
        Dim str As String
        Dim ans As Integer
        str = "Delete from asps where ctid = " & txtcustid.Text & ""

        Dim cmd As New OleDbCommand(str, cn)
        ans = cmd.ExecuteNonQuery

        MsgBox("Deleted:" & ans)
        GridView1.DataBind()
        cn.Close()

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Protected Sub btncancle_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncancle.Click
    txtproid.Text = ""
    txtcustid.Text = ""
    txtcustname.Text = ""
    txtproname.Text = ""
    txtissudate.Text = ""
End Sub

End Class

Edit

Pub: 28 Sep 2023 13:42 UTC

Views: 42