Jump to content

Recommended Posts

I have created an on-line registration form. I have 3 mysql tables. One for the company info, one for the attendee info and one for the spouses info.

I am trying to figure out how to properly write the code to insert the form data into the mysql tables and to email both the user and website owner with the info. 

 

I am receiving the following error:

 

Parse error: syntax error, unexpected $end in c:\... at the end of the document.

 

<?php
include_once "connection.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
// form has been submitted, create variables with POST array
if($_GET[act] == "sub") {
     $company = $_POST[company];
     $address = $_POST[address];
     $city = $_POST[city];
     $state = $_POST[state];
     $zip = $_POST[zip];
     $contact = $_POST[contact];
     $phone = $_POST[phone];
     $email = $_POST[email];
     mysql_query("INSERT INTO zone5_company (company, address, city, state, zip, contact, 
phone, email, date) VALUES ('$company', '$address', '$city', '$state', '$zip', '$contact', '$phone', '$email' CURDATE())");
// get value from previous insert operation, zone5_company
$tid = mysql_insert_id();
// insert attendee info into zone5_attendee table
$attendeeQuery = "INSERT INTO zone5_attendees (id, attendee_name, company)VALUES";
for ($j=1; $j<=20; $j++) {
     $count=0;
     // if the attendee_name is not empty
     if ($_POST['attendee_name' . $j] != "") {
           if ($j != 1) {
                 $attendeeQuery .= ",";
     }
     $attendeeQuery .= "('" . $_POST['attendee_name' . $j] . "','" . $tid . "')";
     $count++;
     }
// insert spouse info into zone5_spouses table
$spouseQuery = "INSERT INTO zone5_spouses (id, spouse_name, company)VALUES";
for ($j=1; $j<=10; $j++) {
     $count2=0;
     if ($_POST['spouse_name' . $j] != "") {
           if ($j != 1) {
                 $spouseQuery.= ",";
     }
     $spouseQuery .= "('" . $_POST['spouse_name' . $j] . "','" . $tid . "')";
     $count2++;
     }
}
mysql_query($attendeeQuery);
mysql_query($spouseQuery);
// e-mail to 
// compose e-mail
$to = "a@aaaa.com"; // 
$subject = "New Zone 5 Registration Form";
$headers = "From: $company <$email>";
$body = "A new Zone 5 Registration Form has been submitted by $company\n";
$body .= "with $count attendee(s) and $count2 spouse(s).\n\n";
// send the email
mail($to, $subject, $body, $headers);
// e-mail to attendee
// compose e-mail
$to = "$email"; // contact at company email
$subject - "Received Your Zone 5 Registration";
$body = "Thank you for your zone 5 registration. This is our confirmation.\n\n";
$body .= "Fair, Festival or Association: $company\n";
$body .= "$address\n";
$body .= "$city, $state $zip\n";
$body .= "Your registration is for $count attendees and $count2 spouses\n\n";
$attendees = mysql_query("SELECT company from zone5_company ORDER by id ASC");
$attendeeArray = array();
$attendeeArray[0] = "n/a";
while ($thisCompany = mysql_fetch_object($attendees)) {
     array_push($attendeeArray, $thisCompany->company);
}
for($k=1; $k<=20; $k++) {
     if($_POST['attendee_name' . $k] != "" ) {
           $body .= $_POST['attendee_name'. $k] . "\n\n";
     }
}
//send
mail($to, $subject, $body, $headers);
header("location: $PHP_SELF?act=done");
}
?>
<head>
<title>$sitename</title>
<link rel="stylesheet" type="text/css" href="form_style.css" />
</head>
<body>
<?php
if($_GET[act] == "done") {
?>
We have received your registration. Thank you for entering online.
<?php
} else {
?>
<h1>2008 Zone 5 Conference Registration Form</h1>
<p>Membership to the IAFE is not required to attend this conference. Registration fees are 
$70 per attendee for registrations received prior to February 1. Beginning February 1, the 
registration fee is $95 per attendee.</p>
<p>Lodging is not included in the registration fee. </p>
<form action="<?PHP_SELF ?>?act=sub" method="post" name="zone5" >
<fieldset>
<legend>Fair, Festival or Business Information</legend>
<p>
<label for="name">Fair, Festival or Business Name</label>
<input type="text" id="company" id="company" />
</p>
<p>
<label for="address">Address</label>
<input type="text" id="address" name="address" />
</p>
<p>
<label for ="city">City</label>
<input type="text" id="city" name="city" />
</p>
<p>
<label for="state">State</label>
<input type="text" id="state" name="state" />
</p>
<p>
<label for="zip">Zip Code</label>
<input type="text" id="zip" name="zip" />
</p>
<p>
<label for="contact">Contact</label>
<input type="text" id="contact" name="contact" />
</p>
<p>
<label for="phone">Phone</label>
<input type="text" id="phone" name="phone" />
</p>
<p>
<label for="email">E-mail address</label>
<input type="text" id="email" name="email" />
</p>
</fieldset>
<fieldset>
<legend>Attendee Information</legend>
<p>Enter the name(s) of the person(s) that will be attending the Zone 5 Conference. <br 
/><br />
<?php
for($i=1; $i<=20; $i++) {
?>
<label for="attendee_name . <?php echo $i; ?>">Attendee Name</label>
<input type="text" id="attendee_name . <?php echo $i; ?>" name="attendee_name . <?php echo 
$i; ?>" />
<br />
<?php
} 
?>
</p>
</fieldset>
<fieldset>
<legend>Spouse Program Participants</legend>
<p>Enter the name(s) of the spouse(s) that will be participating in the Zone 5 Spouse 
Program. <br /><br />
<?php
for($i=1; $i<=10; $i++) {
?>
<label for="spouse_name . <?php echo $i; ?>">Spouse Name</label>
<input type="text" id="spouse_name . <?php echo $i; ?>" name="spouse_name . <?php echo $i; 
?>" />
<br />
<?php
}
?>
</p>
</fieldset>
<fieldset>
<legend>Special Accommodation Needs</legend>
<p>
<label for="special">Special accommodatons required (dietary requirements, etc)</label>
<input type="text" id="special" name="special" size="100" />
</p>
</fieldset>
<fieldset>
<legend>Payment</legend>
<p>
<input type="radio" id="pmtMethod" name="pmtMethod" value="credit" checked="checked" />
Credit Card<br />
<input type="radio" id="pmtMethod" name="pmtMethod" value="check" />
Check by Mail
</p>
</fieldset>
<p><input type="submit" value="Submit" /></p>
</form>
<?php
}
?>
<? include "aaa.php"; ?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/84538-php-form-arrays/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.