Flash/php contact form problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrwaterfield
Forum Newbie
Posts: 3
Joined: Wed Oct 27, 2004 4:15 am

Flash/php contact form problem

Post by mrwaterfield »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is the code I have on the submit button of my flash 'contact' form. It points at a PHP script that is supposed to put the contact info into a mysql database. However something isn't working and I trying to isolate the problem.
Can anybody see anything obviously wrong with it?
Going a bit crazy with this...
Thanks a lot
mark

Code: Select all

on (release) {
if (checkboxname.selected == true) {
info = "yes";
} else {
info = "no";
}
if ((!Email.length || Email.indexOf("@") == -1) || Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail address";
} else if (!FirstName.length) {
EmailStatus = "Please enter your name before sending";
} else if (!ToComments.length) {
EmailStatus = "Please enter some text in your message";
} else {
loadVariablesNum("MailPHP10.php", 0);
EmailStatus = "Sending... ";
}
}
Here is the PHP script as well if it any help...

Code: Select all

<?php
$dbhost = "127.0.0.1"; // Your database host here user..user.mysql.somehost.net 
$dbusername = "******"; // Your database username here
$dbpw = "********"; // Your database password here
$dbname = "markwaterfield_com_-_contact"; // Database name here
$postvars = array("FirstName", "Email", "ToComments","HearAbout","info");
foreach ($postvars as $var)
if(isset($_POST[$var]))
$$var = $_POST[$var];

$connection = mysql_connect($dbhost, $dbusername, $dbpw) or die(mysql_error());
mysql_select_db($dbname, $connection); 
$query = "INSERT INTO `sarah1` VALUES ('$FirstName', '$Email', '$ToComments', '$HearAbout','$info');";

mysql_query($query, $connection) or die(mysql_error());
mysql_close($connection);
Print "_root.Mail.EmailStatus=Complete - Your contact info has been sent";
?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you describe what "isn't working?"
User avatar
ed209
Forum Contributor
Posts: 153
Joined: Thu May 12, 2005 5:06 am
Location: UK

Post by ed209 »

it looks like you're trying to send and receive data. You're sending the info from the form and receiving a success message from the PHP script.

Have you tested the PHP page on it's own?

I would temporarily change your $_POST's to $_GET's and use a URL to test the script, i.e.

Code: Select all

your_php_page.php?var1=some_data&var2=some_more_data
(having said that you'll probably end up sending the variables as GET anyway)


Have you tested your flash form?

It's difficult to test dynamic content so use the following method for tracing your flash form:

http://www.joshbuhler.com/2004/11/20/us ... a-browser/

For this sort of thing I use sendAndLoad().
Post Reply