I have a html form below:
<section id="main" style="float: right; text-align: left; width: 83%;">
<article>
<form>
<p>Name: <div><input id="name" type=text/></p></div><br \>
<p>Phone: <div><input id="phone" type=text/></p></div><br \>
<p>Address: <div><input id="address" type=text/></p></div><br \>
<p>Username: <div><input id="username" type=text/></p></div><br \>
<p>Password: <div><input id="password" type="password"/></p></div><br \>
<p>Email: <div><input id="email" type="text"/></p></div>
<div><input id="submitDB" type="submit" value="Register"/></div>
</form>
<script type="text/javascript">
$('#submitDB').on('click', function() {
event.preventDefault();
$.ajax({
url: "registerDB.php",
data: { name: $('#name').val(), phone: $('#phone').val(), address: $('#address').val(), username: $('#username').val(), password: $('#password').val(), email: $('#email').val()},
type: "POST"
}).done(function(data) {
if(data === "true"){
alert(data);
}
else
{
alert(data);
}
});
});
</script>
</article>
</section>
This form should submit the inputs and call a "registerDB.php" file which contains
<?php
require_once("config.php");
require_once("MysqliDb.php");
$DB = new MysqliDb($DBCREDS['HOSTNAME'], $DBCREDS['USERNAME'], $DBCREDS['PASSWORD'], $DBCREDS['DATABASE']);
$name = $_POST["name"];
$phone = $_POST['phone'];
$address = $_POST['address'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$data = Array ("name" => $name,
"phone" => $phone,
"address" => $address,
"email" => $email,
);
var_dump($data);
if($DB->insert('member', $data))
{
$user = Array (
"username" => $username,
"password" => $password,
);
var_dump($user);
die();
if($DB->insert('member_login', $user))
{
echo "You are now registered!";
}
}
else
{
echo "Please Fill All Data And Resubmit";
}
?>
However the username and password variables are not passing through. Is there something I am missing here? This does not have to be super "secure" I am working on a project for my System Analysis class and basically am working on making a website for a presentation.