I know this has been asked before, and I have copied the results from other questions but I still am not seeing results.
I am trying to add results to my DB when the form is submitted.
Currently, the form will run but there are no results being added to the DB. If I uncomment out the echo statement, I am able to see that so it is running through the IF statement.
I know I have to just be missing something obvious so any help is very appreciated.
Thank you!
** Disregard security holes & sloppy HTML code for now. Just need to get Step 1 working before I make adjustments.
<form method="post" action="post-me.php">
<div class="form-element">
<label for="utm_url"><b>*</b> Enter URL</label>
<input type="text" name="utm_url" id="utm_url">
</div>
<div class="form-element">
<label for="utm_campaign"><b>*</b> Enter Campaign</label>
<select name="utm_campaign" id="utm_campaign">
<option selected> </option>
<option>test-campaign-1</option>
<option>test-campaign-2</option>
<option>test-campaign-3</option>
</select>
</div>
<div class="form-element">
<label for="utm_source"><b>*</b> Enter Source</label>
<select name="utm_source" id="utm_source">
<option selected> </option>
<option>google</option>
<option>facebook</option>
<option>bing</option>
</select>
</div>
<div class="form-element">
<label for="utm_medium"><b>*</b> Enter Medium</label>
<select name="utm_medium" id="utm_medium">
<option selected> </option>
<option>organic</option>
<option>referral</option>
<option>cpc</option>
</select>
</div>
<div class="form-element">
<label for="utm_content">Enter Content</label>
<input type="text" name="utm_content" id="utm_content">
</div>
<div class="form-element">
<label for="utm_keyword">Enter Keyword</label>
<input type="text" name="utm_keyword" id="utm_keyword">
</div>
<div class="form-element">
<label for="utm_date">Date Created</label>
<input type="date" name="utm_date" id="utm_date">
</div>
<div class="form-element">
<label for="utm_description">Enter Description</label>
<input type="text" name="utm_description" id="utm_description">
</div>
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])) {
#DB Variables
$db['db_host'] = "localhost";
$db['db_user'] = "BLANK";
$db['db_pass'] = "BLANK";
$db['db_name'] = "BLANK";
#Changing values into constants.
foreach($db as $key => $value){
define(strtoupper($key), $value);
}
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
#Sending form data to sql db.
mysqli_query($connection,
"INSERT INTO linkArchive (URL, Campaign, Source, Medium, Content, Keyword, Description, theDate)
VALUES ('$_POST[utm_url]', '$_POST[utm_campaign]', '$_POST[utm_source]', '$_POST[utm_medium]', '$_POST[utm_content]', '$_POST[utm_keyword]', '$_POST[utm_description]', '$_POST[utm_date]')");
// echo('IT RAN');
// header("Location: http://website.com");
// exit();
}
?>