<?php
if ($_POST['Submit'] == 'Join Now')
{
	//validate form
	$validform = trim($_POST['validform']);
	if (strtolower($validform) != "joyscreamer"){
	echo "<p>The form was not validated. Use your back button to try again.</p>";
		 exit;
	} else {
	//getform fields
	$lastname = trim($_POST['lastname']);
	$firstname = trim($_POST['firstname']);
	$addr1 = trim($_POST['addr1']);
	$addr2 = trim($_POST['addr2']);
	$city = trim($_POST['city']);
	$state = trim($_POST['state']);
	$zip = trim($_POST['zip']);
	$country = trim($_POST['country']);
	$email = trim($_POST['email']);
	$phone = trim($_POST['phone']);
	$station = trim($_POST['station']);
	$comments = trim($_POST['comments']);
	// email form data to joyce
		$to      = 'info@joyscream.com';
		$from    = $email;
		$headers = "From: $from";
		$subject = 'Joyscream Mailing List Form Submitted';
		$message = "The following information was submitted via the email list sign up form on Joyscream.com:\n\n";
		$message = $message."Last Name: ".$lastname."\n";
		$message = $message."First Name: ".$firstname."\n";
		$message = $message."Address 1: ".$addr1."\n";
		$message = $message."Address 2: ".$addr2."\n";
		$message = $message."City: ".$city."\n";
		$message = $message."State: ".$state."\n";
		$message = $message."Zip: ".$zip."\n";
		$message = $message."Country: ".$country."\n";
		$message = $message."Email: ".$email."\n";
		$message = $message."Phone: ".$phone."\n";
		$message = $message."Station: ".$Station."\n";
		$message = $message."Comments: "."\n".$comments."\n";
		// Send the message
		$ok = @mail($to, $subject, $message, $headers);
		if ($ok) {
		 //echo "<p>Mail sent! Yay PHP!</p>";
		} else {
		 echo "<p>Mail could not be sent. Sorry!</p>";
		 exit;
		}
	//say thanks
	header("Location: jointhanks.html");
	echo "submitted done.";
	exit;
	}
}
?>
<HTML>  
<HEAD>
  <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Mac">
  <TITLE>Join the Joyscream Mailing List</TITLE>
  <META NAME="Classification" CONTENT="general">
  
 <script language="JavaScript" type="text/JavaScript">
<!--
  function validate() {
    if (! isValidEmail(document.contactform.email.value)) {
        alert("Please enter a valid email address");
        return false;
    }
    return true;
  }
function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    }
	
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
//-->
</script>
</HEAD>
<body bgcolor="#FFFFFF" background="images/Joyscream.gif">
<form name="contactform"  action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return validate();" >

<P>&nbsp;</P>

<H1><FONT SIZE="+2">
</FONT>Join Joyce Andersen's Mailing List</H1>

<P><HR ALIGN="LEFT"><FONT SIZE="+1">
Hello Folks!
<br><br>
Thanks for joining our mailing list. We don't share your information. 
We just want to let you know when Joyce is playing near you or when 
she has some news you might like to hear about....new recordings, 
grammy nominations etc. If you prefer email make sure you let us know 
what town and state you live in or you won't receive emails for 
particular gigs in your region.
<br><br>
thanks!
<br><br>
the Joyscreamers
</FONT><p></P>

<BR>
<TABLE CELLPADDING="1" CELLSPACING="3" BORDER="0">
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="100" nowrap>Last Name:</TD> 
    <TD><INPUT TYPE="text" SIZE="22" NAME="lastname"> &nbsp; &nbsp;
      First Name: <INPUT TYPE="text" SIZE="29" NAME="firstname"></TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Address:</TD> 
    <TD><INPUT TYPE="text" SIZE="60" NAME="addr1"></TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Address:</TD> 
    <TD><INPUT TYPE="text" SIZE="60" NAME="addr2"></TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">City:</TD> 
    <TD>
        <INPUT TYPE="text" SIZE="25" NAME="city">
         &nbsp; &nbsp; State/Province:
      <INPUT TYPE="text" SIZE="20" NAME="state"></TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Zip/Postal:</TD> 
      <TD> 
        <input type="text" size="20" name="zip">
        &nbsp; &nbsp; Country: 
        <INPUT TYPE="text" SIZE="25" NAME="country" VALUE="USA">
      </TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Email:</TD> 
    <TD>
        <INPUT TYPE="text" SIZE="35" NAME="email">
        <B> Please join
      our e-mail list. It's a better way.</B></TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Telephone:</TD> 
    <TD><INPUT TYPE="text" SIZE="30" NAME="phone"> If you want us
      to be able to call you.</TD> 
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Radio station:</TD> 
    <TD><INPUT TYPE="text" SIZE="30" NAME="station"> What radio station(s)
      do you like?</TD> 
  </TR>
  <TR VALIGN="MIDDLE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Note:</TD> 
    <TD><TEXTAREA NAME="comments" ROWS="5" COLS="60" WRAP="physical">
Anything else you want to tell us? Type it here.
      </TEXTAREA></TD> 
  </TR>
  <TR>
    <TD SIZE="150"></TD>
    <TD><img src="images/validation.gif" width="250" height="80">   
  </TR>
  <TR VALIGN="BASELINE" ALIGN="LEFT">
    <TD ALIGN="RIGHT" SIZE="150">Validate Form :</TD>
    <TD><INPUT NAME="validform" TYPE="text" id="validform" SIZE="30">
    Enter Text from image above to validate form </TD>
  </TR>
  <TR>
    <TD SIZE="150"></TD>
    <TD><INPUT name="Submit" VALUE="Join Now" TYPE="submit"><BR>

  </TR>
</TABLE>
<HR ALIGN="LEFT">
 <p align="left"><!--#include virtual="jfooter.html" --><font color="#FFFFFF">Anderson Anderson Anderson</font></p>
</form>