Good evening SO. I'm a complete newbie when it comes to HTML, CSS, JS, PHP, and the like, so I need some help, particularly with some PHP and JQuery.
I'm trying to submit a simple email from an HTML form. Here's the HTML/ JQuery snippet of that happening:
<form action="" id="emailform" name="emailform">
          <input type="email" class="form-control" name="email_submit_field" id="email_submit_field" placeholder="type your email here">
          <input id="email_submit_button" class="btn btn-default" role="button" type="submit" value="Submit"></input>
</form>
<script>    
    $("form").submit(function(event){
            event.preventDefault();
            $.post("email.php", $("#emailform").serialize());
    });
</script>
From there, it is supposed to open up email.php. God knows if it is even doing that right, let me know please. But anyways, once it gets into email.php, it aims to post that email value to a mySQL database running on localhost. Here's the PHP I have to accomplish that:
<?php
$dbname = "test";
$host = "localhost";
$usr = "root";
$pass = "password"; //obviously not, but you get the point
$email = $_POST["email_submit_field"];
$cxn = new mysqli($host, $usr, $pass, $dbname);
$query = "INSERT INTO emails VALUES('$email')";
mysqli_query($query);
mysqli_close();
?>
The big problem that I have with all of this is that it seems like every single tutorial does this in a different way, none of which work for me. Long story short, the mySQL database never receives the data, and I have no idea why. Any and all assistance is appreciated, and hopefully someone can help me understand how (in a simple and consistent way) to access a mySQL database via PHP. Thank you in advance SO.
 
     
     
     
     
    