Hi-
I am trying to insert first name, last name and email into a database when they hit a submit button. Its not working so I’ve come here for help.
this is one frame one with my 3 input boxes and button:
instance names:
fname
lname
email
submit
stop();
var dataOut:LoadVars = new LoadVars();
errortxt.autoSize = true;
function sendUserName() {
if (fname.text == "" || lname.text == "" || email.text == "") {
errortxt.text = "Please fill in all fields.";
} else {
dataOut.fnametxt = fname.text;
dataOut.lnametxt = lname.text;
dataOut.emailtxt = email.text;
dataOut.send("user.php");
_root.gotoAndStop(2);
}
}
submit.addEventListener("click", sendUserName);
and then my php
<?
$firstName = $_POST['fnametxt'];
$lastName = $_POST['lnametxt'];
$email = $_POST['emailtxt'];
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$sql="INSERT INTO assessment (fname, lname, email) VALUES ('$firstName','$lastName','$email')";
if(!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
any help would be great thanks.