Basically, I've always used php forms on regular sites, and I finally integrated one with flash.
Here is my code first of all:
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<?php
session_register("SESSION");
?>
</p>
<form name="form1" method="post"
action="<?php echo $me;?>">
</form>
<?php
}
else {
if (!session_is_registered("SESSION")){
$errors[] = "Invalid form submission";
}
// initialize a variable to
// put any errors we encounter into an array
$errors = array();
// check to see if a name was entered
if (!$_POST['name'])
// if not, add that error to our array
$errors[] = "Please include your name";
// check to see if a number was entered
if (!$_POST['number'])
// if not, add that error to our array
$errors[] = "Please include a Phone Number where you can be reached";
// check to see if a message was entered
if (!$_POST['message'])
// if not, add that error to our array
$errors[] = "Please include the Project Details";
// if there are any errors, display them
if (count($errors)>0){
echo "<strong>ERROR:<br>\n";
foreach($errors as $err)
echo "$err<br>\n";
} else {
// no errors, so we build our message
$recipient = 'info@__________.com';
$from = stripslashes($_POST['name']);
$extra = "Reply-To: $email\r\n";
$subject = "A visitor to __________.com has emailed you";
$msg = "Message from $from.
$from's phone number is $number and their email address is $email.
Here is the message that they sent you:\n\n"
.stripslashes($_POST['message']) ;
if (mail($recipient,$subject,$extra,$msg,$from))
echo "Thank you for you interest. We will get back to you shortly.\n\n\n
You may now close this window.";
else
echo "An unknown error occurred.";
}
}
?>
Here is the corressponding email that is sent to [email]info@______.com[/email]
Message from Juan Carlos.
Juan Carlos's phone number is 703-858-8863 and their email address is [email]JC@JC.com[/email].
Here is the message that they sent you:
I am interested in a new patio for my very expensive mansion.
Reply-To: JC@JC.com
Most everything is resolved except for two issues:
1) 'from:' on clients
No matter what I have tried, I cannot get the email that is inputted in the form to display in the header when it is recieved. All I get is "nobody" and the name of the DNS server my host uses.
For reference, the variables passed to POST from my flash site are:
-name
-email
-number
-message
2) email format. I edited the code to make the emails a little more presentable for but can only do so much. They client's message, in this case, "I am interested..." ends up left-jsutified and while everything above it is center-justified. I don't necessarily want soemthign as flashy as an HTML message with pictures and such, but that would be nice. Really, all I am interested in is making everything easier to read
Thanks🙂