Tuesday, December 24, 2024

Task 3: Create a HTML index page with only one form field with name and submit it in to database age using insert command

lets create a database named age and create table using name age with follwing command .

create database age;

use age;

create table age(sn int auto_increment primary key, num int);

<html>
<body>
<form action='submit.php' method='post'>
<input type='number' name='num'>
<input type='submit'>
</form>
</body>
</html>

  Now lets create another page naming submit.php

<?php
$conn = mysqli_connect('localhost', 'ksumanadhikari', 'welcome', 'age') or die("Connection failed");
$num = $_POST['num'];
$sql = "INSERT INTO age(num) VALUES ('$num')";

mysqli_query($conn, $sql);
mysqli_close($conn);  // Corrected line: added the closing parenthesis
?>

Web view 

S.K.A

0 comments:

Post a Comment

Copyright © Web Devloper LogBook | Powered By Blogger | Blogger Templates
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com