I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms.
i use this function to add more guestnames and guestemail fields based on the number of guests added.
form.php
Expand|Select|Wrap|Line Numbers
- function createGuestNameAndEmailElements()
- {
- var newHTML;
- newHTML='';
- for (var i = 2; i <= document.getElementById('numGuests').value; i++) {
- newHTML=newHTML+'<div style="float:left; left:0px; top:0px; width:100px; margin-top:5px; margin-right:10px;"><input name="guestNames" id="guestNames" type="text" value="Guest Name" class="lpWhite" style="width:100px;" /></div><div style="float:left; left:0px; top:0px; width:160px; margin-top:5px;"><input name="guestEmails" id="guestEmails" type="text" value="Guest Email Address" class="lpWhite" style="width:160px;" /></div><div style="clear:both;"></div>';
- }
- document.getElementById('guestNamesAndEmails').innerHTML = newHTML;
- //document.getElementById('guestNames').focus();
- }
[PHP]<?php error_reporting(0); ?>
<?php
include('function.php');
// Receiving variables
@$eventDate = addslashes($_POST['eventDate']);
@$venueName = addslashes($_POST['venueName']);
@$fullName = addslashes($_POST['fullName']);
@$emailAddress = addslashes($_POST['emailAddress']);
@$guestNames = addslashes($_POST['guestNames']);
@$guestEmails = addslashes($_POST['guestEmails']);
@$table = addslashes($_POST['table']);
//Sending auto respond Email to visitor
$pfw_header = "From: vip@1com\n"
. "Reply-To: vip@1.com\n";
$pfw_subject = "1.Com - Guest List - $venueName";
$pfw_email_to = "$emailAddress";
$pfw_message = "THIS IS NOT A CONFIRMATION EMAIL\n"
. "\n"
. "Hey $_REQUEST[fullName],\n"
. "\n"
. "If we have not responded by then please e-mail us at: Vip@1.Com with your fullname and query.\n"
. "\n"
."Venue Details:\n"
. "Date: $_REQUEST[eventDate]\n"
. "Venue: $_REQUEST[venueName]\n"
. "Table Booking: $_REQUEST[table]\n"
. "\n"
. "Your Guests:\n"
. "$_POST[guestNames]"
. "\n"
. "\n"
. "-\n"
. "Kind Regards\n"
. "The 1 Team\n"
. "---\n"
. "www.1.Com\n"
. "---\n"
. "\n"
. "The information contained in this message and any attachments is intended for the addressee only and may contain confidential and/or privileged information. If you are not the intended recipient, please destroy this message immediately. You should not copy, use or distribute this message for any purpose, nor disclose all or any part of its contents to any other person. Any views or opinions expressed in this message are those of the author and do not necessarily represent those of 1 LTD. 1 LTD disclaims any liability for any action taken in reliance on the content of this message.";
//Sending Email to form owner
$pfw_header2 = "From: $emailAddress\n"
. "Reply-To: $emailAddress\n";
$pfw_subject2 = "$eventDate - $venueName - Guest List";
$pfw_email_to2 = "vip@1.com";
$pfw_message2 = "Event Date: $_REQUEST[eventDate]\n"
. "Venue: $_REQUEST[venueName]\n"
. "Full Name: $_REQUEST[fullName]\n"
. "Email Address: $_REQUEST[emailAddress]\n"
. "Guests: \n"
. "$_POST[guestNames], $_POST[guestEmails]\n"
. "\n"
. "Table: $_REQUEST[table]\n"
. "\n"
. "Notes: \n"
. "$_REQUEST[notes]";
//Sending auto respond Email to visitor guests
$pfw_header3 = "From: vip@1.com\n"
. "Reply-To: vip@1.com\n";
$pfw_subject3 = "1.Com - Guest List - $venueName";
$pfw_email_to3 = "$guestEmails";
$pfw_message3 = "THIS IS NOT A CONFIRMATION EMAIL\n"
. "\n"
. "Hey $_REQUEST[guestNames],\n"
. "\n"
. "$_REQUEST[fullName], has used V-Parties guest list service and has added you to his guest list for:\n"
. "\n"
."Venue Details:\n"
. "Date: $_REQUEST[eventDate]\n"
. "Venue: $_REQUEST[venueName]\n"
. "\n"
. "Your Guests:\n"
. "$_POST[guestNames]"
. "\n"
. "\n"
. "-\n"
. "Kind Regards\n"
. "The 1 Team\n"
. "---\n"
. "www.1Com\n"
. "---\n"
. "\n"
. "The information contained in this message and any attachments is intended for the addressee only and may contain confidential and/or privileged information. If you are not the intended recipient, please destroy this message immediately. You should not copy, use or distribute this message for any purpose, nor disclose all or any part of its contents to any other person. Any views or opinions expressed in this message are those of the author and do not necessarily represent those of 1 LTD. 1 LTD disclaims any liability for any action taken in reliance on the content of this message.";
/* Validation */
if ($_POST['fullName']=='' || alpha_numeric($_POST['fullName'])<3)
{
$errors[] = 'A fullname is required and be more than 3 characters';
}
if ($_POST['numGuests']=='' || valid_guests($_POST['numGuests'])<2)
{
$errors[] = 'A number of guests must be over 2';
}
if ($_POST['emailAddress']=='' || valid_email($_POST['emailAddress'])==FALSE)
{
$errors[] = 'A valid e-mail address is required';
}
if(is_array($errors))
{
echo '<p class="error"><b>The following errors occured</b></p>';
while (list($key,$value) = each($errors))
{
echo '<span class="error">'.$value.'</span><br />';
}
}
else {
echo '<p><b>Success!</b></p>';
echo '<span>Your guest list was successfully processed. A confirmation email has been sent to your email mailbox.</span>';
//send e-mails
mail("$pfw_email_to", "1.Com - Guest List - $venueName", "$guestNames, $pfw_message", "From: vip@1.com", "-f"."vip@1.com");
mail("vip@1.com", "$eventDate - $venueName - Guest List", "$pfw_message2", "From: $_REQUEST[emailAddress]", "-f".$_REQUEST[emailAddress]);
mail("$_POST[guestEmails]", "1.Com - Guest List - $venueName", "$guestNames, $pfw_message3", "From: vip@1.com", "-f"."vip@1.com");
//saving record in a text file
$pfw_file_name = "Data.csv";
$pfw_first_raw = "Fullname,Email\r\n";
$pfw_values = "$fullName,$emailAddress\r\n";
$pfw_values = "$guestNames,$guestEmails\r\n";
$pfw_is_first_row = false;
if(!file_exists($pfw_file_name))
{
$pfw_is_first_row = true ;
}
if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {
die("Cannot open file ($pfw_file_name)");
exit;
}
if ($pfw_is_first_row)
{
if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
die("Cannot write to file ($pfw_filename)");
exit;
}
}
if (fwrite($pfw_handle, $pfw_values) === FALSE) {
die("Cannot write to file ($pfw_filename)");
exit;
}
fclose($pfw_handle);
}
?>[/PHP]
now the problem is, if i choose 4 guests in the field and the form generates for me 4 fields to fill in.
only the last field's information will show in the email sent.
if anyone could help out that would be great.
Thanks.