PDA

View Full Version : Flash PHP mySQL - Submit form data to database



Digitalosophy
December 17th, 2004, 12:42 AM
I'll start it off :)

Learn how to set up a mySQL database, a Flash form, and a PHP page which will submit the Flash data into your database.

http://digitalosophy.com/experiments/archive/flash/dbInterv2.zip

msblack7of940
September 20th, 2005, 08:19 PM
hi, does anyone else have this file cause it's no longer available at the link.
thanks
7:)

msblack7of940
September 20th, 2005, 08:39 PM
hi everyone, i did some searching and i found an interesting article that looks like it can do what i need. i'll check it out and post back but here's the link:


www.4alltemplates.com/article_info.php/articles_id/49 (http://www.4alltemplates.com/article_info.php/articles_id/49)

7:)

Templarian
September 20th, 2005, 11:07 PM
Here this could help u out. its a fully functioning login system.

www.templarian.com/kirupa/log.zip (http://www.templarian.com/kirupa/log.zip)

//edit, although it doesnt have all the fancy checking stuff so its easier to understand.

miss7of9
September 22nd, 2005, 04:08 PM
gosh i forgot to say that i am using flash mx not 2004 and i can't open the flash file.

also, what i'm really looking for is a script that will send an email and send the results to a mysql database. i found the email form script here at kirupa and it works perfectly but now i want to send the results to a database.

can someone help me out with a script or tutorial?

thanks
7:)


Here this could help u out. its a fully functioning login system.

www.templarian.com/kirupa/log.zip (http://www.templarian.com/kirupa/log.zip)

//edit, although it doesnt have all the fancy checking stuff so its easier to understand.

Templarian
September 22nd, 2005, 04:41 PM
easy enough.

//edit, and i will explain it just use this portion chang ethe variables name and use


if($email=="undefined" || $subject=="undefined" || $message=="undefined"){
echo "Please fill in all the fields";
}else{
echo "Thankyou for registering.";
mysql_connect("localhost", "tablename", "password");
mysql_select_db("databasename");
mysql_query("INSERT INTO tablename (`email`,`subject`,`message`) VALUES ('$email','$subject','$message')");
here is the full script:

<?php
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

if($email=="undefined" || $subject=="undefined" || $message=="undefined"){
echo "Please fill in all the fields";
}else{
echo "Thankyou for registering.";
mysql_connect("localhost", "tablename", "password");
mysql_select_db("databasename");
mysql_query("INSERT INTO tablename (`email`,`subject`,`message`) VALUES ('$email','$subject','$message')");
}
?>

miss7of9
September 23rd, 2005, 12:45 PM
thanks Templarian i'll try it out and post back! ;)

miss7of9
September 23rd, 2005, 03:54 PM
oooooooooh you are wonderful Templarian!!!!! I got it. lol. what i did was add the above script to the email script i already had (had to figure that part out). yall let me know if you want me to post the entire script that allows you to do both.

thanks again,
7 :beam:

lbeetles
September 23rd, 2005, 09:52 PM
Please post the whole scrip as ive been looking for something like this for my site.

Templarian
September 24th, 2005, 12:08 AM
happy i could help. although the Omega gave me the script a little while back when i was learning this stuff.

msblack7of940
September 26th, 2005, 11:14 PM
<?php
/************************************************** *\
* PHP 4.1.0+ version of email script. For more
* information on the mail() function for PHP, see
* http://www.php.net/manual/en/function.mail.php
\************************************************* **/


// First, set up some variables to serve you in
// getting an email. This includes the email this is
// sent to (yours) and what the subject of this email
// should be. It's a good idea to choose your own
// subject instead of allowing the user to. This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.

$sendTo = "email@company.com";
$subject = "Contact Form";

// variables are sent to this PHP page through
// the POST method. $_POST is a global associative array
// of variables passed through this method. From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.


// header information not including sendTo and Subject
// these all go in one variable. First, include From:
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
// next include a replyto
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
// often email servers won't allow emails to be sent to
// domains other than their own. The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path: " . $_POST["email"];

// now we can add the content of the message to a body variable
$message = $_POST["message"] . "\r\n";
$message .= "email: " . $_POST['email'] . "\r\n";
$message .= "subject: " . $_POST['subject'] . "\r\n";

// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);

if($email=="undefined" || $subject=="undefined" || $message=="undefined"){
echo "Please fill in all the fields";
}else{
echo "Thankyou for registering.";
mysql_connect("localhost", "username", "password");
mysql_select_db("databasename");
mysql_query("INSERT INTO tablename (`email`,`subject`,`message`) VALUES ('$email','$subject','$message')");
}

?>

msblack7of940
September 26th, 2005, 11:33 PM
hi Templarian,
is the part before the database info suppose to be form validation? if so then i just realized that it didn't work for me. i was able to only fill in one field and it went through without any errors. is there a way to do the validation directly in Flash and if so where does it go with this script for the send button?

on (release) {
// send variables in form movieclip (the textfields)
// to email PHP page which will send the mail
form.loadVariables("email.php", "POST");
}

thanks and i hope you can help with this also.
7:)

Templarian
September 27th, 2005, 04:35 PM
Becuase It just checks if the user is trying to hit the send button by accedent. (the code uses || (or) when u could just use &&(and).

msblack7of940
September 27th, 2005, 09:56 PM
sorry Templarian, i have no idea what you are talking about. lol. can you help me out with a code for validation?
thanks again
7:)


Becuase It just checks if the user is trying to hit the send button by accedent. (the code uses || (or) when u could just use &&(and).

Templarian
September 27th, 2005, 11:10 PM
there is only a few 1 spot in your entire code that uses "or" ||, you just have to make it say "and" &&.

if(this1 == "" && this2== "" && this3 == ""){
all values are empty.
}
goodnight.

danielelvito
November 25th, 2007, 07:27 AM
where is fla and php .. source ?

mikedkap
August 15th, 2008, 12:07 PM
Does anyone have a finished version of this I could check out? :party:

-Kap

marlopax
December 20th, 2008, 02:22 PM
Is there anyone who can give the source file of this work?
All the above links are not working............
I need it

please help

prototype
December 21st, 2008, 06:56 PM
Maybe this one will be helpful:
http://www.scotflash.co.uk/blog/?p=46

Good luck!

hungree
October 30th, 2009, 12:28 PM
I've been using this thread as reference. I'm trying to have my flash form send, through a PHP file, to an email AND to the mySQL database I've setup. Here is what I've got:

<?php
/*----------------------------------------------------------
Author : www.mkeefedesign.com | Matthew Keefe
Contact : matt@mkeefedesign.com
$Id: send_email.php ,v 1.0 Tue Apr 26, 2005 02:20 PM
------------------------------------------------------------
* CODING & DESIGN ©2004 mkeefeDESIGN | ALL RIGHTS RESERVED
------------------------------------------------------------*/

$recipients = "sturbaindesigns@gmail.com" . ",";
$subject = "Skin Survey";

// Grab the key from Flash to ensure security
$sendKey = $_POST['key'];

// Only allow the page to send if Flash is the requester
if($sendKey == "email") {
// The following three variables are gathered from Flash
$name = $_POST['name'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$street = $_POST['street'];
$province = $_POST['province'];
$postal = $_POST['postal'];
$city = $_POST['city'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$phone = $_POST['phone'];


// Grab todays date
$date = date("F j, Y", time());

// This block is the actual message that is sent in the email
$email_info .= "Below is the visitors contact info and message.\n\n";
$email_info .= "Visitor's Info:\n";
$email_info .= "-----------------------------------------\n";
$email_info .= "First Name: " . $name . "\n";
$email_info .= "Last Name: " . $lname . "\n";
$email_info .= "Email: " . $email . "\n";
$email_info .= "Street: " . $street . "\n";
$email_info .= "Province: " . $province . "\n";
$email_info .= "Postal Code: " . $postal . "\n";
$email_info .= "City: " . $city . "\n";
$email_info .= "Gender: " . $gender . "\n";
$email_info .= "DOB: " . $dob . "\n";
$email_info .= "Phone: " . $phone . "\n";

$email_info .= "Date Sent: " . $date . "\n\n";
$email_info .= "-----------------------------------------\n";

$mailheaders = "From: <sturbaindesigns@gmail.com> \n";
$mailheaders .= "Reply-To: " . $email . "\n\n";

if(mail($recipients, $subject, $email_info, $mailheaders)) {
print "&success=true";
mysql_connect("localhost", "dbusername", "dbpass");
mysql_select_db("dbname");
mysql_query("INSERT INTO english_results (`name`, `lname`, `email`, `street`, `province`, `postal`, `city`, `gender`, `dob`, `phone`) VALUES ('$name','$lname','$email','$street','$province',' $postal','$city','$gender','$dob','$phone')");

}
}

?>

I've used myphpadmin to setup my database and the table english_results. When I execute I receive the email but I don't get anything in my database. Any ideas what I'm doing wrong?