I’m pretty weak when it comes to forms, there seems to be something I am missing here, the mysql table is not being populated when a form is submitted and as far as information on the web goes, there is plenty on how to make forms, plenty on php, plenty on mysql but I am not finding anything that works that syncs the three, this is what I have:
Form (no worries, ill make the styles external as soon as I get the functionality down):
<div style="background-color:#424142; width:100%; margin-left:7%; margin-top:20px;">
<form action="templates/tmpl_tmd022/scripts/post_subscription.php" method="post">
<table width="100%" border="0">
<tr>
<td style="padding:5px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;" colspan="2">Sign up now to recieve our free newsletter. </td>
</tr>
<tr>
<td style="padding:5px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;" width="30%">First name:</td>
<td style="padding:5px; padding-left:0; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;" width="70%"><input type="text" name="fname" /></td>
</tr>
<tr>
<td style="padding:5px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;">Last name:</td>
<td style="padding:5px; padding-left:0; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;"><input type="text" name="lname" /></td>
</tr>
<tr>
<td style="padding:5px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;">Email:</td>
<td style="padding:5px; padding-left:0; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#FFF;"><input type="text" name="email" /></td>
</tr>
<tr>
<td style="padding:5px;"> </td>
<td style="padding:3px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:12px; color:#000;"><input type="submit" value="Submit" style="color:000;"/></td>
</tr>
</table>
</form>
</div>
PHP:
<?php
require "connect_to_mysql.php";
$fname=($_POST['fname']);
$lname=($_POST['lname']);
$email=($_POST['email']);
$sql="INSERT INTO subscriptions (lname, fname, email)
VALUES ('$_POST[lname]','$_POST[fname]','$_POST[email]')";
mysql_close();
header('Location: http://www.*websitehidden*.com/')
?>
The included connect_to_mysql.php file is the db name, db user, and db password, it is tested and functioning fine.
Does anyone have any idea as to what (probably stupid) mistake I am making?
You have not included the mysql_query() part that executes your query.
Also the mysql_ function should not be used they are the old way of doing things and are not as fast and secure as the newer mysqli_ functions.