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