I am experiencing problems running the following PHP code:
Get_Words_And_Display.php:
<?php
require('Database.php');
$word_w = $_POST['word'];
$word_def = $_POST['def'];
$word_cat = substr($word_w, 0, 1);
$SQLQueryIns = "INSERT INTO all_words (Category, Words, Definition) VALUES ('$word_cat', '$word_w', '$word_def')";
$MySQL_db->exec($SQLQueryIns); //PDO Object is assigned to $MySQL_db
$SQLQueryGet = "SELECT * FROM all_words";
$SQLGet = $MySQL_db->query($SQLQueryGet);/*Each value is displayed in a table using foreach*/ ?>
Here is what I want the application to do:
1) User enters values in Create_Word.php
2) Create_Word.php POSTS the values to Get_Words_And_Display.php
3) Get_Words_And_Display.php processes values and displays the values
However the POST values from Create_Word.php is not displayed (There are no errors).
My Database works completely fine, it's just the Get_Words_And_Display.php.
What am I doing wrong here?
Here is the Create_Word.php file:
<form action="Get_Words_And_Display.php" method="POST">
<div style="border-top:dotted; border-width:2px; margin-top: 10px; padding-top: 20px;">
<p>
<label for="word">Word:</label>
<input type="text" name="word" />
</p>
<p>
<label for="definition">Definition:</label>
<textarea name="def"></textarea>
</p>
<input type="submit" />
</div>
</form>
My foreach code in located within the Get_Words_And_Display.php file:
<?php foreach($SQLGet as $AllResults) : ?>
<tr>
<td class="dataCell"><?php echo $AllResults['Category']; ?></td>
<td class="dataCell"><?php echo $AllResults['Word']; ?></td>
<td class="definition"><?php echo $AllResults['Definition']; ?></td>
</tr>
<?php endforeach; ?>