I am not the best coder in PHP but here is what I am trying to do.
I created a form and when they click submit I want to run some code before the e-mail and data is saved. What I need to do is check the database to see if what they are entering already exists. If it exists it will not post the data and tell them it's already been entered. If it does not exist it will continue and post the data to the DB.
My issue is that the form submit does not continue with posting the data, how do I make this happen? In other words if the data is not in the DB already how do I continue on the submit proccess so that the data is placed in the DB.
Thanks
Form code:
I created a form and when they click submit I want to run some code before the e-mail and data is saved. What I need to do is check the database to see if what they are entering already exists. If it exists it will not post the data and tell them it's already been entered. If it does not exist it will continue and post the data to the DB.
My issue is that the form submit does not continue with posting the data, how do I make this happen? In other words if the data is not in the DB already how do I continue on the submit proccess so that the data is placed in the DB.
Thanks
Form code:
<?php
global $my, $mosConfig_live_site, $database;
?>
<fieldset>
<legend>Enter Your Odomitor Reading</legend>
<label for="enterdate">Date: <?php echo date("m/d/Y")?></label>
<input type="hidden" name="enterdate" id="enterdate" value="<?php echo date("m/d/y")?>" readonly="readonly" />
<br />
<label for="name">Name: <?php echo $my->name ?></label>
<input name="name" id="name" value="<?php echo $my->name?>" readonly="readonly" type="hidden" />
<br />
<label for="millage">Current Odomitor Reading: </label>
<input type="text" size="6" name="millage" />
</fieldset>
<input type="submit" value="send" />
On Submit Code - Before Send:<?php
$sql = "SELECT millage from #__chronoforms_1 where name like '".$_POST['name']."'";
$database->setQuery($sql);
$rows = $database->loadObjectList();
foreach($rows as $record)
{
if ($record->millage == $_POST['millage'])
{
echo "You have already posted this odomitor reading.";
}
}?>