# Trying to input text to database

**URL:** <https://forum.kirupa.com/t/trying-to-input-text-to-database/222782>\
**Category:** Uncategorized\
**Created:** [April 16, 2007, 10:46pm UTC](https://forum.kirupa.com/t/trying-to-input-text-to-database/222782 "2007-04-16T22:46:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [April 16, 2007, 10:46pm UTC](https://forum.kirupa.com/t/trying-to-input-text-to-database/222782/1 "2007-04-16T22:46:49Z")

</div>

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

```auto

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

```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.
