I have a little page that is just supposed to make a table in mysql from post data and then redirect to "second_page.php" but for some reason, after the form submits, it doesnt redirect.
<?php
$connection =mysqli_connect("localhost", "widget_cms", "password", "widget_corp");
?>
<html>
<body>
<form name="login" action="login.php">
Username: <input type="text" name="username"></br>
<input name="submit" type="submit" value="Submit" style="cursor:pointer">
</form>
<?php
$username = $_POST['username'];
$username = mysqli_real_escape_string($connection, $username);
$query = "INSERT INTO subjects (menu_name) VALUES ('{$username}')";
if(isset($_POST['submit'])){
$qresult = mysqli_query($connection, $query);
if($qresult){
header("Location: second_page.php");
}else{
die("Error " . mysqli_error($connection) . " "
. "(" . mysqli_errno($connection) . ")" .",
Please contact Sammy for troubleshooting as soon as you can.");
}
}
?>
</body>
</html>
<?php
mysqli_close($connection);
?>
Also for some reason it doesnt make a table, not sure what im doing wrong there either.