Hi,
I've taken a look at the DB code you sent me, and have adjusted it below.
Just copy this to your fmhookpreemail.inc.php file (replacing the current contents), and make the appropriate changes for database connection, and you should be fine:
PHP Code:
<?php
include("../scripts/under_neath/dbinfo.inc9.php");
$con = mysql_connect("host","username","password");
if (!$con)
{
Error('database','Could not connect: ' . mysql_error()); /* this also exits the script */
}
$name = mysql_real_escape_string($aCleanedValues['name'],$con);
$lastname = mysql_real_escape_string($aCleanedValues['lastname'],$con);
$email = mysql_real_escape_string($SPECIAL_VALUES['email'],$con);
mysql_select_db("applications", $con);
$sql="INSERT INTO e9 ('name', 'lastname', 'email')
VALUES
('$name','$lastname','$email')";
if (!mysql_query($sql,$con))
{
Error('database','Insert failed: ' . mysql_error()); /* this also exits the script */
}
mysql_close($con);
Things to note:- Your original query was not correct, so I've fixed that.
- Your form fields are in FormMail arrays. Most of them are in an array called $aCleanedValues, some are in $SPECIAL_VALUES as they are FormMail special fields.
- Generally, the only two special fields you'll be interested in retrieving are "email" and "realname": $SPECIAL_VALUES['email'] and $SPECIAL_VALUES['realname'] .
- These two arrays contain sanitized data - this means FormMail has cleaned the data from hacks and dangerous strings that might be attacks.
- Each field you put in the MySQL query must be escaped with a called to "mysql_real_escape_string" (otherwise certain inputs can cause the query to fail).
That's it!
Good luck.
Bookmarks