# Inserting data into a database using Flash

**URL:** <https://forum.kirupa.com/t/inserting-data-into-a-database-using-flash/71624>\
**Category:** flash\
**Created:** [November 27, 2004, 5:35am UTC](https://forum.kirupa.com/t/inserting-data-into-a-database-using-flash/71624 "2004-11-27T05:35:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mprzybylski](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mprzybylski/32/613_2.png) [@mprzybylski](https://forum.kirupa.com/u/mprzybylski)\
**Post date:** [November 27, 2004, 5:35am UTC](https://forum.kirupa.com/t/inserting-data-into-a-database-using-flash/71624/1 "2004-11-27T05:35:49Z")

</div>

I have a little application with five text fields and a submit button that i want to put the inputted data from into a database. i have my database done and everything, and here is the code for the PHP file i’m using:

```php
<?php
$server = "localhost";
$username = "reintro_matt";
$password = " *******";
$database = "reintro_testdb";
$table = "ecard";

mysql_pconnect($server, $username, $password);
mysql_select_db($database);

$success = 1;

$ins_str = "INSERT INTO " . $table . " VALUES ('".$HTTP_POST_VARS['fromName']."', '".$HTTP_POST_VARS['fromEmail']."', '".$HTTP_POST_VARS['toName']."', '".$HTTP_POST_VARS['toEmail']."', '".$HTTP_POST_VARS['message']."')";

//echo $ins_str;

if (!mysql_query ($ins_str)) {
    $success = 0;
    $msg = 'Problem saving records to the database';
} else {
    $msg = 'Record was saved successfully. Refreshing display...';
}

echo '&success='.$success.'&msg='.$msg.'&';

?> 

```

i’m not very good with PHP but after doing some research and reading some tutorials i think that is good to go. my text fields in flash have the variables that i’m using in the POST\_VARS commands in PHP and similar instance names. how would i go about writing the actionscript to collect this data and insert it into the database in flash (or make corrections to the PHP i already have if it isn’t ready).

thanks in advance.
