Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97355

PHP file wont insert HTML data into SQL server

$
0
0

I created a HTML form and gave it the action of my php file and the method of post.

HTML:

<form action="Data.php" style="position: fixed; top: 60px; left: 5px;" method="POST">
                <fieldset>
                    <legend>Create Account</legend>
                    Username: <br>
                    <input type="text" name="username">
                    <br>
                    Email:<br>
                    <input type="text" name="email">
                    <br>
                    Password:<br>
                    <input type="text" name="password">
                    <br><br>
                    <input type="submit" value="Create">
                </fieldset>
              </form> 

And i get the data from the form into this php file:

<?php
    // retrieve the form data by using the element's name attributes value as key
    $email = $_POST['email'];
    $username = $_POST['username'];
    $pass = $_POST['password'];

    $conn = mysqli_connect("localhost:3306", "mysql.default_user", "mysql.default_password");
    $db = mysqli_select_db("UserInfo", $conn);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = "INSERT INTO Users (email, passwrd, username) VALUES ('".$email."', '".$pass."', '".$username."')";

    $result = mysqli_query($conn, $sql);

    $conn->close();
?>

and the php is supposed to send it to an sql server i made in Microsoft sql Server Management and i connected the server to vs code, which is where im doing all of my coding.


Viewing all articles
Browse latest Browse all 97355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>