Posted by:
c2dan
(---.15-1.cable.virginmedia.com)
This is not a a form help with code, but I'll help anyway
Is a form being posted to that script? If it is you should only execute these lines of code
$sql = "INSERT INTO testTable (uName, uNum) VALUES ('$_POST[uName]', '$_POST[uNum]')";
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}
When the form is submitted.
Otherwise a blank record will be added to your tetsTable as the $_POST variables do not exists yet. The most common way to achieve this is to name your submit button in your form as
submit. Now change the above lines I mentioned to
[php]// check that form is submitted
if(isset($_POST['submit'])) {
$sql = "INSERT INTO testTable (uName, uNum) VALUES ('$_POST[uName]', '$_POST[uNum]')";
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}
}[/php]
Now a record will only be added when the form is submitted.