Posts

  9th prgrm form.html <form action="submit.php" method="post">     Name: <input type="text" name="name"><br><br>     Email: <input type="email" name="email"><br><br>     <input type="submit" value="Submit"> </form> submit.php <?php // Step 1: Connect to MySQL $conn = mysqli_connect("localhost", "root", "", "myformdb"); // Step 2: Check connection if (!$conn) {     die("Connection failed: " . mysqli_connect_error()); } // Step 3: Read form data $name = $_POST['name']; $email = $_POST['email']; // Step 4: Insert into table $sql = "INSERT INTO users (name, email) VALUES ('$name', '$email')"; if (mysqli_query($conn, $sql)) {     echo "Record added successfully!"; } else {     echo "Error: " . mysqli_error($conn); } // Step 5: Close connection my...

PHP

 1. Prime Numbers <?php function isPrime($n) {     if ($n <= 1)         return false;     for ($i = 2; $i <= sqrt($n); $i++) {         if ($n % $i == 0)             return false;     }     return true; } $start = 3; $end = 20; $count = 0; for ($i = $start; $i <= $end; $i++) {     if (isPrime($i)) {         echo "$i \t";         $count++;     } } echo "<br>The Total number of Prime numbers are = $count"; ?> 2. Message Passing (Form and Receiver Page) form.html: <html> <style>     body { background-color: lightblue; } </style> <center>     <form action="p2p.php" method="post">         Enter the Message:         <input type="text" name="msg"><br><br>         <input typ...