I am currently trying to execute an INSERT INTO when a search button is clicked. Eventually I'd like to submit the search term into the database, however I'm currently just trying to submit a simple string to ensure the initial INSERT INTO works correctly, which it currently doesn't.
I have the following:
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="search" name="search" id="results" placeholder="Enter search">
<input type="submit" name="submit" class="frstBtn" value="searchterm"><br>
</form>
<?php
$searchterm = "";
?>
<?php
if(isset($_POST['submit']))
{
$sql = "INSERT INTO tableName (variableName) VALUES ('test')";
$results = mysqli_query($conn,$sql) or die(mysqli_error());
}
?>
The latter php function, search, works perfectly fine, but the former function including the INSERT INTO does not.
Here is the table itself in phpmyadmin.
I have successfully manually copied and pasted the actual INSERT INTO statement into the actual database and it has worked fine, so I know the issue isn't with the statement. Any help is much appreciated. Thanks.