So I recently started a project and am using a little bit of a different method than I would usually do to post forms and I have no clue why it will not post. I have 2 other post forms that are setup identically to this one and they work fine
Here is the actual form, the include just leads to the database information and a seperate form that includes all of the materials that I am using to call posts.
<?php include('check.php') ?><title>Create New License</title> <link rel="stylesheet" type="text/css" href="../include/css/style.css">
<div class="header"> <h2>Admin - create License</h2> </div> <form method="post" action="create_license.php"> <div class="input-group"> <label>License Key</label> <input type="key" name="key"> </div> <div class="input-group"> <label>Type of Key</label> <select type="type" name="type" id="user_type"> <option value="1">7 days</option> <option value="2">30 days</option> <option value="3">Lifetime</option> </select> </div> </div> <input type="hidden" name="addlicense"value="test"> </div> <div class="input-group"> <button type="submit" class="btn" name="license_create_btn"> + Create license</button> </div> </form>
// call the licensecreate() function if license_create_btnis clicked
if (isset($_POST[‘license_create_btn’])) {
licensecreate();
}
// CREATE LICENSE
function licensecreate(){
// call these variables with the global keyword to make them available in function global $db, $errors; // receive all input values from the form. Call the e() function // defined below to escape form values $key = e($_POST['key']); $type = e($_POST['type']); // form validation: ensure that the form is correctly filled if (empty($key)) { array_push($errors, "License Key is required"); } if (count($errors) == 0) { if (isset($_POST['type'])) { $query = "INSERT INTO license (key, type) VALUES('$key', '$type')"; mysqli_query($db, $query); $_SESSION['success'] = "New License successfully created!!"; header('location: home.php'); }else{ header('location: index.php'); } }
}
I’m not sure if this could just be a database issue or php as I am not getting any errors output in either mysql or php