Hello,
Coming back to PHP after a year with ColdFusion. I'm trying to create a self-posting form that validates the form elements, then if all are ok, inserts into the database. Somehow, it's not working the query string isn't being written, and I can't quite figure this out.
Here's the code:
<?php
if(isset($POST['submit'])){
//set a flag to indiciate if form is ready to submit
$RTG = TRUE;
if(empty($formVars["fName"]))
$fNameFlag= "The First Name field cannot be empty.";
$RTG = FALSE;
}
if($RTG == TRUE){//OK to insert into Database
$fName = addslashes($POST['fName']);$fName = trim($_POST['fName']);
$query = "INSERT INTO subscribers
(fName)VALUES('$fName')";
It appears that $RTG is not being set correctly (to FALSE) if $fNameFlag is true.
Thanks,
James