lecture 38

<?php

$server = "localhost";
$username = "root";
$pass = "";
$dbName = "mydb";


$conn  = mysqli_connect($server, $username, $pass, $dbName);



?>



<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <form>
        <center>
            Name
            <input type="text" name="userName">
            <br>
            <br>

            email
            <input type="email" name="userEmail">
            <br>
            <br>

            Address
            <input type="text" name="userAddress">
            <br>
            <br>
            <input type="submit" name="submit" value="Insert">
            <br>
            <input type="radio" name="english" value="male" id="">
        </center>

    </form>


    <?php

    // if (isset($_REQUEST['userName']) && isset($_REQUEST["userEmail"]) && isset($_REQUEST["userAddress"]))

    if (isset($_REQUEST['submit'])) {
        $userName = $_REQUEST["userName"];
        $useremail = $_REQUEST["userEmail"];
        $useraddress = $_REQUEST["userAddress"];
        $checked = $_REQUEST["english"];
        echo $checked;

        $query = "INSERT INTO user(name, email, address) VALUES('$userName','$useremail', '$useraddress')";

        // $result = mysqli_query($conn, $query);


        // if ($result) {
        //     echo "Data inserted";
        // } else {
        //     echo mysqli_error($conn);
        // }
    }



    ?>
</body>

</html>

Comments