'html form input not uploading text to mysql database

html form not inputting text inside mysqldatabase.

        <div id="form-div">
            <form method="post" id="form-space" action="manage_content.php">
                <h6 id="close-text">close</h6>
                <input type="text" name="webname" id="webname" placeholder="Title"
                required="required"/>
                <input type="text" name="url" id="addurl" placeholder="url" required="required"/>
                <input type="submit" name="submit" value="Add Link" id="addlink"/>
            </form>         
        </div>

manage_content.php

<?php
$serverName = "localhost";
$dBUsername = "root";
$dBPassword = "";
$dBName = "registration";
$conn = mysqli_connect($serverName, $dBUsername, $dBPassword, $dBName);
if (!$conn) {
    die("Connection fails: " . mysqli_connect_error());
}
if(isset($_POST["submit"])){
    $webname = $_POST["webname"];
    $url = $_POST["url"];
    $sql = "INSERT INTO post (webname, url) VALUES (?, ?)";
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_prepare($stmt, $sql)) {
        die(mysqli_error($conn));
    }
    mysqli_stmt_bind_param($stmt, "ss", $webname, $url);
    mysqli_stmt_execute($stmt);
}
?>

both the html file and the php is in the same directory but, it is not working. Can't figure out the problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source