Syntax Errors?

PHP Code:


 /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		$email = " ";
		$connection = new PDO('mysql:host=worldreviewgroupcom.*****mysql.com;dbname=emailcollection' , "worldreviewgroup" , "*******");
		if (!$connection){
			die('Could not connect: ' . mysql_error());
	   }
		
		function showWindowAndValidate()
		{
			echo'	<p>Join the Mailing List!</p>
					<div id="activeemailbox">
					<form name="form1" method="post" action="">
					  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>          
					  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
					  <label for="name">Enter Your Name:</label>
					  <input type="text" name="name" value="" maxlength="60" /><br />
					  <label for="age">Enter Your Age:</label>
					  <input type="text" name="age" value="" maxlength="3" /><br />
					  <label for="country">Select Your Country:
					  <select name="country">
						 <option selected="selected">United States</option>
						 <option>United Kingdom</option>
						 <option>Canada</option>
						 <option>Australia</option>
						 <option>Russia</option>
						 <option>Brazil</option>
						 <option>Somewhere Else</option>
					  </select><br />
						  <input type="submit" value="Sign Me Up!" onclick="" />
					</form>
					</div>';
			writeUserToDatabase($email, $name, $age, $country, $category);
		}
		
		if (isset($_POST["go"]){
			$email = $_POST["go"];
			if (isItAValidEmail($email)){
				showWindowAndValidate();
			} else {
				invalidEntry();
		} else {
			invalidEntry();
			}
		
		/*test the e-mail address submission for valid entry */
		function Boolean isItAValidEmail($email){
			if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
			  return false;
			} else {
			  return true;
			}
		}
		
		function invalidEntry()
		{
			return echo'<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
		}
		
		function generateRandom()
		{
		
		}
		
		function goBack()
		{
			header();
		}
		
		function writeUserToDatabase($email, $name, $age, $country, $category)
		{
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email)
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
		}
		
		$connection = null;
	}
	//end e-mail box scripting section
?>

There is apparently a problem with the $email variable, it doesn’t like the braces in many spots. What have I done incorrectly thus far?

I’m… my brain hurts a little bit trying to follow the bouncing code, tbh.

Which line is it thats throwing the error?

First thing that popped up to me was this

		function invalidEntry()
		{
			return echo'<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
		}

You can’t return an echo statement… Or at least you shouldn’t be able to! Figure out what you really want to do, do you want to return a value, or echo a string when this function is called. From your code, I think you just want to echo your string, so remove the return statement and leave the rest.

I… believe it’s still valid syntax (cant test atm). Pointless syntax, but valid. It would return the return of echo, which is void, so you’d get Null ( I think).
You should still not do this. Either echo straight out, or return the string and echo the return value.

I suspect it’s because of all the code that’s inside the class but not inside a function.

		$email = " ";
		$connection = new PDO('mysql:host=worldreviewgroupcom.*****mysql.com;dbname=emailcollection' , "worldreviewgroup" , "*******");
		if (!$connection){
			die('Could not connect: ' . mysql_error());
	   }

This code is inside the class but not inside the constructor or any other method/function block. Then a little farther down, there’s more…

		if (isset($_POST["go"]){
			$email = $_POST["go"];
			if (isItAValidEmail($email)){
				showWindowAndValidate();
			} else {
				invalidEntry();
		} else {
			invalidEntry();
			}

All that inside the class but not inside a function. And there may be still more yet, so keep looking.

P.S. to the OP: Many more people could have helped you a lot quicker and a lot easier if you had supplied that actual error message. Help us to help you. :wink: Also, make sure you keep your code well formatted, especially when you suspected that a stray brace was the problem. Look at your original post and look at the first closing brace. It’s lined up with the class brace, but actually it’s the closing “if” brace.

Yeah, well, I’m trying really hard to learn this stuff. Thanks for all the replies.

I figured out the return echo hiccup in there, so I just got rid of the return statement because that function is for displaying markup or going back to the previous page after it’s done.

There’s a problem with the first line with the $email class variable.

Parse error: syntax error, unexpected ‘$email’ (T_VARIABLE), expecting function (T_FUNCTION) in C:\xampp\htdocs\index.php on line 392

, & I also forgot to put in the parentheses in an if statement, but the spot below- it doesn’t like the else statement here:


		if (isset($_POST["go"])){
			$email = $_POST["go"];
			if (isItAValidEmail($email)){
				showWindowAndValidate();
			} else {
				invalidEntry();
		} else {
			invalidEntry();
		}

It says there’s an error at that bottom else.

The other spot located is:


$statement -> bindParam(':name', $name);

It’s unfinished as well because I need to create a function that cycles through some random letters and numbers in image files I made to catch spam. I haven’t done all that I want to do in the PDO section as well.

New code:


<?php
	  /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		$email = " ";
		
		function showWindowAndValidate()
		{
			echo'	<p>Join the Mailing List!</p>
					<div id="activeemailbox">
					<form name="form1" method="post" action="">
					  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>          
					  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
					  <label for="name">Enter Your Name:</label>
					  <input type="text" name="name" value="" maxlength="60" /><br />
					  <label for="age">Enter Your Age:</label>
					  <input type="text" name="age" value="" maxlength="3" /><br />
					  <label for="country">Select Your Country:
					  <select name="country">
						 <option selected="selected">United States</option>
						 <option>United Kingdom</option>
						 <option>Canada</option>
						 <option>Australia</option>
						 <option>Russia</option>
						 <option>Brazil</option>
						 <option>Somewhere Else</option>
					  </select><br />
						  <input type="submit" value="Sign Me Up!" onclick="" />
					</form>
					</div>';
			writeUserToDatabase($email, $name, $age, $country, $category);
			
			/*test the e-mail address submission for valid entry */
			function isItAValidEmail($email){
				if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
				  return false;
				} else {
				  return true;
				}
			}
		}
		
		if (isset($_POST["go"])){
			$email = $_POST["go"];
			if (isItAValidEmail($email)){
				showWindowAndValidate();
			} else {
				invalidEntry();
			}
		} else {
			invalidEntry();
		}
		

		
		function invalidEntry()
		{
			$markup = '<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
			echo $markup;
		}
		
		function generateRandom()
		{
		
		}
		
		function goBack()
		{
			header();
		}
		
		function writeUserToDatabase($email, $name, $age, $country, $category)
		{
			$connection = new PDO(
'mysql:host=worldreviewgroupcom.fatcowmysql.com;dbname=emailcollection' , "worldreviewgroup" , "monkey88");
		if (!$connection){
			die('Could not connect.');
	   }
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email)
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
			$connection = null;
		}
		
		
	}
	//end e-mail box scripting section
?>

//and it actually still doesn’t like the if and else statement, but it’s fine with the nested ones.

As Jeff pointed out previously

		if (isset($_POST["go"])){
			$email = $_POST["go"];
			if (isItAValidEmail($email)){
				showWindowAndValidate();
			} else {
				invalidEntry();
			}
		} else {
			invalidEntry();
		}

Is still not within a function. You need to figure out which function, that block of code should be a part of.

I would also remove this block

			/*test the e-mail address submission for valid entry */
			function isItAValidEmail($email){
				if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
				  return false;
				} else {
				  return true;
				}
			}

Outside of the function showWindowAndValidate()

Yes, this helped greatly.

Now I’m only down to one error, the second bindParam statement for my PDO function in writeUserToDatabase(). Any idea?

New code


<?php
	  /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		
		function showWindow()
		{
			$email = " ";
			if (isset($_POST["go"])){
				$email = $_POST["go"];
				if (isItAValidEmail($email)){
			} else {
				invalidEntry();
			}
				echo'	<p>Join the Mailing List!</p>
						<div id="activeemailbox">
						<form name="form1" method="post" action="">
						  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>          
						  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
						  <label for="name">Enter Your Name:</label>
						  <input type="text" name="name" value="" maxlength="60" /><br />
						  <label for="age">Enter Your Age:</label>
						  <input type="text" name="age" value="" maxlength="3" /><br />
						  <label for="country">Select Your Country:
						  <select name="country">
							 <option selected="selected">United States</option>
							 <option>United Kingdom</option>
							 <option>Canada</option>
							 <option>Australia</option>
							 <option>Russia</option>
							 <option>Brazil</option>
							 <option>Somewhere Else</option>
						  </select><br />
							  <input type="submit" value="Sign Me Up!" onclick="writeUserToDatabase()" />
						</form>
						</div>';
				
				/*test the e-mail address submission for valid entry */
			} else {
				invalidEntry();
			}
			
			function isItAValidEmail($email){
				if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {					  				return false;
				} else {
				  return true;
				}
			}
		}
		

		
		function invalidEntry()
		{
			$markup = '<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
			echo $markup;
		}
		
		function generateRandom()
		{
		
		}
		
		function goBack()
		{
			header();
		}
		
		function writeUserToDatabase($email, $name, $age, $country, $category)
		{
			$connection = new PDO(
'mysql:host=w*********.********.com;dbname=emailcollection' , "world********up" , "******");
		if (!$connection){
			die('Could not connect.');
	   }
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email)
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
			
			/* send welcome e-mail and notification to me */
			function sendEmails();
			{
					
			}
			$connection = null;
		}
		
		
	}
	//end e-mail box scripting section
?>

missing a semi-colon on

$statement -> bindParam(':email', $email)

Yes, thank you! No more syntax errors.

Now this is the error I’m getting after putting the site files to my local testing server and testing the site. It looks okay visually, but when I try to use the e-mail box form at the bottom, I get this error message:

Parse error: syntax error, unexpected ‘$email’ (T_VARIABLE) in C:\xampp\htdocs\Scripts\email.php on line 12

This is the current code


<?php
	  /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		
		function showWindow()
		{
			$email = " ";
			if (isset($_POST["go"])){
				$email = $_POST["go"];
				if (isItAValidEmail($email)){
			} else {
				invalidEntry();
			}
				echo'	<p>Join the Mailing List!</p>
						<div id="activeemailbox">
						<form name="form1" method="post" action="">
						  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>          
						  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
						  <label for="name">Enter Your Name:</label>
						  <input type="text" name="name" value="" maxlength="60" /><br />
						  <label for="age">Enter Your Age:</label>
						  <input type="text" name="age" value="" maxlength="3" /><br />
						  <label for="country">Select Your Country:
						  <select name="country">
							 <option selected="selected">United States</option>
							 <option>United Kingdom</option>
							 <option>Canada</option>
							 <option>Australia</option>
							 <option>Russia</option>
							 <option>Brazil</option>
							 <option>Somewhere Else</option>
						  </select><br />
							  <input type="submit" value="Sign Me Up!" onclick="writeUserToDatabase()" />
						</form>
						</div>';
				
				/*test the e-mail address submission for valid entry */
			} else {
				invalidEntry();
			}
			
			function isItAValidEmail($email){
				if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {					  				return false;
				} else {
				  return true;
				}
			}
		}
		

		
		function invalidEntry()
		{
			$markup = '<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
			echo $markup;
		}
		
		function generateRandom()
		{
		
		}
		
		function goBack()
		{
			header();
		}
		
		function writeUserToDatabase($email, $name, $age, $country, $category)
		{
			$connection = new PDO(
'mysql:host=blank;dbname=blank' , "username" , "password");
		if (!$connection){
			die('Could not connect.');
	   }
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email);
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
			
			$connection = NULL;
		}
		
		
	}
	//end e-mail box scripting section
?>

Actually, in that form’s markup there, it had an action attribute of “Scripts/email.php” that was causing it to crash. No error!

Now it just does nothing after you enter an e-mail address, instead of echoing that small extended form.

What am I missing for it to make that form come up?

I’ll try adding some CSS styles in for the id of “activeemailbox” that was referenced in that div in that echoed markup.

Look at the braces. Make sure they all match up.

Progress so far:

No syntax errors or errors, but a box sure doesn’t at least come up with that echo statement. I’m not telling this to show this 2nd form window right apparently.

Code PHP:


 <?php
	  /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		
		function processEmail()
		{
			$email = " ";
			if (isset($_POST["go"])){
				$email = $_POST["go"];
				showWindow();
			} else {
				invalidEntry();
			}
		}
	
		function showWindow()
		{
			echo   '<p>Join the Mailing List!</p>
					<div id="activeemailbox">
					<form name="form1" method="post" action="">
					  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>
					  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
					  <label for="name">Enter Your Name:</label>
					  <input type="text" name="name" value="" maxlength="60" /><br />
					  <label for="age">Enter Your Age:</label>
					  <input type="text" name="age" value="" maxlength="3" /><br />
					  <label for="country">Select Your Country:<span style="color:red">*</span></label>
					  <select name="country">
							 <option selected="selected">United States</option>
							 <option>United Kingdom</option>
							 <option>Canada</option>
							 <option>Australia</option>
							 <option>Russia</option>
							 <option>Brazil</option>
							 <option>Somewhere Else</option>
					   </select><br />
					   <input type="submit" value="Sign Me Up!" />
					</form>
					</div>';
					
				$confirmedEmail = $_POST["confirmemail"];
				$name = $_POST["name"];
				$age = $_POST["age"];
				$country = $_POST["country"];
				$category = getCategory();
					
				if (isset($confirmedEmail) && $email == $confirmedEmail){
					writeUserToDatabase($confirmedEmail, $name, $age, $country, $category);
				}
			}
		}
			
		/*test the e-mail address submission for valid entry */
		function isItAValidEmail($email){
			if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {					  			return false;
			} else {
			  return true;
			}
		}
		
		function getCategory()
		{
			$currentURL= $_SERVER['PHP_SELF'];
			if (preg_match($currentURL, "index"))
				return "Home Page";
			elseif (preg_match($currentURL, "health"))
				return "Health";
			elseif (preg_match($currentURL, "insurance"))
				return "Insurance";
			elseif (preg_match($currentURL, "general"))
				return "General";
			elseif (preg_match($currentURL, "dating"))
				return "Dating";
			elseif (preg_match($currentURL, "education"))
				return "Education";
			elseif (preg_match($currentURL, "legal"))
				return "Legal";
			elseif (preg_match($currentURL, "startyour"))
				return "Business Opportunities";
			elseif (preg_match($currentURL, "business"))
				return "Business Services";
		}
		
		function invalidEntry()
		{
			$markup = '<div id="activeemailbox"><p id="error">You didn\\'t enter a valid email, silly!</p><input type="submit" value="Go Back" 		  onclick="goBack()"></div>';
			echo $markup;
		}
		
		function generateRandom()
		{
		
		}
		
		function writeUserToDatabase($email, $name, $age, $country, $category)
		{
			$connection = new PDO(
'mysql:host=worldreviewgroupcom.fatcowmysql.com;dbname=emailcollection' , "worldreviewgroup" , "monkey88");
		if (!$connection){
			die('Could not connect.');
	   }
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email);
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
			
			$connection = NULL;
			goBack();
		function goBack()
		{
			header();
		}
		}
		
		
	//end e-mail box scripting section
?>

Maybe this has to do with the form onclick attributes that I’m trying to use. Maybe the echoed form’s submit input needs an onclick value.

Markup:


      <form id="emailbox" name="form1" method="post">
        <div>
          <input type="text" name="go" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
          <input type="submit" value="Join" onclick="showWindow()" />
        </div>
      </form>

You shouldn’t be echoing any html at all out of your functions. You’re just making your code very hard to change in the future.

Also, this isn’t object oriented code by the way. It’s just a bunch of functions wrapped in an object, which is not what OOP is all about…

Thank you for saying what I was thinking earlier and didn’t have time to post :slight_smile:

@etidd ; One of your fatal flaws in your current code is the fact that you have your presentation (your e-mail form) inside a PHP echo statement, or really, inside PHP period. There are many good reasons to keep your presentation and your business logic (your validation, processing the form submission, etc) separate.

The biggest is, your presentation is static content. You can have a basic HTML page with that form in it and you will then ALWAYS get the output you expect when you pull up that page. By simply doing that step alone, you are making things much easier for yourself, as now you can ALWAYS get to the form you expect to see.

The action of the form would still point to your script. Which will then process the form submission, validate it, and then send the email accordingly. Thus now you have two files with two distinct purposes. The first is solely to show the form to the user, the latter is to actually process the form submission.

Yeah. I MAY have a go at re-writing some of this to show him what we’re on about later. I can’t promise this though as I’m really busy and don’t have much time.

The general idea though is to keep the presentation and business logic separate. Your functions should only be interested in logic and should contain no html or anything like that.

Also - when it comes to OOP, don’t be too disheartened. I started off writing similar code, in that I thought objects were just places to stick a bunch of functions together. I coded like that for some time. It wasn’t until I started reading about design patterns and found out about stuff like polymorphism until I realised I’d been doing it wrong.

I can’t promise I’ll rewrite stuff to show you as I really don’t have much time, but perhaps, depending on how I’m doing later :slight_smile:

Okay, I see what you’re saying. I should create an object and initialize the- methods (Java)- functions with that object.

I also see what you’re saying about the cohesion of my class file, and they should be in two different files that serve their described purposes. This class seems to be very jumbled, and it’s also static because no object is initializing functions. I will attempt to look up how to create an object suitable for running said functions, but if you may provide a guiding light there, I will go ahead and take this on to clean up this code.

Although I wholeheartedly agree, I feel like we should get the OP through these basic syntax errors before we delve into software architecture.

@OP

I hate to sound like a broken record, but you really, really, really need to make sure your braces line up correctly. Look at the last brace in this code below. It looks like you’re closing the function, but actually you’re closing the class.

<?php
	  /*This is the scripting section for the e-mail collection box.*/
	  class CollectEmail
	  {
		
		function processEmail()
		{
			$email = " ";
			if (isset($_POST["go"])){
				$email = $_POST["go"];
				showWindow();
			} else {
				invalidEntry();
			}
		}
	
		function showWindow()
		{
			echo   '<p>Join the Mailing List!</p>
					<div id="activeemailbox">
					<form name="form1" method="post" action="">
					  <label for="confirmemail">Confirm Your E-mail:<span style="color:red">*</span></label>          
					  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
					  <label for="name">Enter Your Name:</label>
					  <input type="text" name="name" value="" maxlength="60" /><br />
					  <label for="age">Enter Your Age:</label>
					  <input type="text" name="age" value="" maxlength="3" /><br />
					  <label for="country">Select Your Country:<span style="color:red">*</span></label>
					  <select name="country">
							 <option selected="selected">United States</option>
							 <option>United Kingdom</option>
							 <option>Canada</option>
							 <option>Australia</option>
							 <option>Russia</option>
							 <option>Brazil</option>
							 <option>Somewhere Else</option>
					   </select><br />
					   <input type="submit" value="Sign Me Up!" />
					</form>
					</div>';
					
				$confirmedEmail = $_POST["confirmemail"];
				$name = $_POST["name"];
				$age = $_POST["age"];
				$country = $_POST["country"];
				$category = getCategory();
					
				if (isset($confirmedEmail) && $email == $confirmedEmail){
					writeUserToDatabase($confirmedEmail, $name, $age, $country, $category);
				}
			}
		}

Second thing: Based on your code, I suspect you come from a Java background. In Java, you could call methods like you would normal functions (e.g., showWindow()). But the same isn’t true in PHP. From inside your class, if you call a static method, it has to be written self::showWindow(), and if you call an instance method, it has to be written $this->showWindow(). And the same is true of class fields: self::$email for static, and $this->email for instance.

Hello everyone,

I have broken this code out into 6 different php files, all with designated class names. I added an HTML file called showwindow.html containing the original index page plus the 2nd form with name,age,country,category, linked to a new style sheet that I’ve created named emailsubmit.css with the new form. This will take a second, but I’ll lay out what I have.

I’d like to make the rest of the page be gray except for the form2 html.

I’m trying to debug the HTML markup because it’s not validating and the entire style sheet is not being applied.

index.php


      <?php
	  //this section is for the e-mail box scripting to begin
	  class PassEmail
	  {
		  function postEmail()
		  {
			  include 'Scripts/emailsubmission.php';
			  $emailPasser = new ProcessEmail;
			  include 'Scripts/finalactions.php';
			  $error = new FinalActions;
		
			  if (isset($_POST["go"])){
			  	$email = $_POST["go"];
				$emailPasser -> getEmail($email);
			  } else {
				$error -> invalidEntry();
			  }
		  }
	  }
	  //end e-mail box scripting section
	  ?>

emailsubmission.php


<?php
	class ProcessEmail
	{
		function gatherEmail()
		{
			$categoryFinder = new CategoryFinder;
			include 'categoryfinder.php';
			$databaseWriter = new DatabaseWriter;
			include 'databasewriter.php';
			$emailSender = new EmailSender;
			include 'emailsender.php';
			$spamCatcher = new SpamCatcher;
			include 'spamcatcher.php';
			$showForm = new ShowWindow;
			include 'showwindow.php';

			$showForm -> showWindow();
				
				if (isset($confirmedEmail) && $email == $confirmedEmail){
					writeUserToDatabase($confirmedEmail, $name, $age, $country, $category);
				} else {
					invalidEntry();
				}
			}
			
			public function getEmail($email)
			{
				$enteredEmail = $email;
			}
		}
?>

emailtester.php


<?php
	class EmailTester
	{
		public function isItAValidEmail($email)
		{
			if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {					  			
			return false;
			} else {
			  return true;
			}
		}
	}
?>

emailsender.php


<?php
	class EmailSender{
		function sendWelcomeEmail()
		{
			
		}
	}
?>

databasewriter.php


<?php
	class DatabaseWriter
	{
		public function writeUserToDatabase($email , $name , $age , $country , $category)
		{
			$connection = new PDO(
'mysql:host=hostname;dbname=emailcollection' , "user" , "password");
		if (!$connection){
			die('Could not connect.');
	   }
			$statement = $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
			$statement -> bindParam(':email', $email);
			$statement -> bindParam(':name', $name);
			$statement -> bindParam(':age', $age);
			$statement -> bindParam(':country', $country);
			$statement -> bindParam(':category', $category);
			$statement -> execute();
			
			$connection = NULL;
		}
	}
?>

categoryfinder.php


<?php
	class CategoryFinder
	{
		public function getCategory()
		{
			$currentURL= $_SERVER['PHP_SELF'];
			if (preg_match($currentURL, "index"))
				return "Home Page";
			elseif (preg_match($currentURL, "health"))
				return "Health";
			elseif (preg_match($currentURL, "insurance"))
				return "Insurance";
			elseif (preg_match($currentURL, "general"))
				return "General";
			elseif (preg_match($currentURL, "dating"))
				return "Dating";
			elseif (preg_match($currentURL, "education"))
				return "Education";
			elseif (preg_match($currentURL, "legal"))
				return "Legal";
			elseif (preg_match($currentURL, "startyour"))
				return "Business Opportunities";
			elseif (preg_match($currentURL, "business"))
				return "Business Services";
		}
	}
?>

finalactions.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
	<body>
    <div id="active"><p id="error">You didn&apos;t enter a valid email, silly!</p><input type="submit" value="Go Back" 	onclick="goBack()"></div>
    <?php
		class FinalActions
		{
			public function invalidEntry()
			{
			
			}
			private function goBack()
			{
				header();
			}
		}
	?>
	</body>
</html>

spamcatcher.php


<?php
	class SpamCatcher
	{
		public function generateCapture()
		{
			
		}
	}
?>

I’ll be working on validation of the markup. Hopefully this will end the styles not being applied.

I probably have a CSS-based question with trying to make the area outside the email submit have a semi-transparent gray mask. See div with id graybox.

showwindow.html


<!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">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   	<link href="style/main.css" type="text/css" media="screen, projection, tv" />
    <link href="style/emailsubmit.css" type="text/css" media="screen, projection, tv" />
    <link href="style/dropdownmenus.css" type="text/css" media="screen, projection, tv" />
    <title>Join the Mailing List at World Review Group!</title>
</head>
	<body>
    <!-- begin container -->
<div id="graymask">
<div id="container">
<!-- begin middle div -->
  <div id="middle">
  <!--header with image -->
    <h1>World Review Group<span></span></h1>
    <div id="body">
      <p id="welcomestatement">Hello everyone, <br />
        This site is dedicated to consumer reviews on current products in many different markets. This site is here to promote the good ones and expose the bad ones. Thank you for visiting!</p>
      <div id="wrapper">
        <!-- begin Personal navigation menu -->
        <ul id="pMenu">
          <li><a href="health.html" title="Health Page">health</a>
            <!-- begin health -->
            <div id="health">
              <!-- weight loss -->
              <h2>weight loss &amp; wellness</h2>
              	  <!-- fitness -->
                  <h3><span>fitness</span></h3>
                  <ul>
                    <li><a href="health/fitness/weiderpowerbell1.html">Weider PowerBell</a></li>
                    <li><a href="health/fitness/brazilbuttlift1.html">Brazil Butt Lift</a></li>
                    <li><a href="health/fitness/georgesstpierre1.html">MMA Training with Georges St. Pierre</a></li>
                    <li><a href="health/fitness/turbofire1.html">TurboFire Fitness</a></li>
                  </ul>
                  <!-- dieting -->
                  <h3><span>dieting</span></h3>
                  <ul>
                    <li><a href="health/dieting/healthetrimdiet1.html">Health&eacute; Trim Diet</a></li>
                    <li><a href="health/dieting/southbeach1.html">South Beach Diet</a></li>
                  </ul>
                  <!-- supplements -->
                  <h2>supplements</h2>
                  <ul>
                    <li><a href="health/Rx/nutrilitevitamins1.html">Nutrilite Multivitamins</a></li>
                    <li><a href="health/Rx/dochangover1.html">Doc Hangover Cure</a></li>
                    <li><a href="health/Rx/libigrow1.html">Libigrow</a></li>
                    <li><a href="health/Rx/smokedeter1.html">Smoke Deter</a></li>
                    <li><a href="health/Rx/prorexin1.html">Prorexin</a></li>
                  </ul>
            <!-- skin care -->
            <h2>skin care</h2>
              <ul>
                <li><a href="health/skincare/shivaacne1.html">Shiva23 Acne Cream</a></li>
                <li><a href="health/skincare/deadseamineral1.html">Dead Sea Mineral Cellulite Treatment</a></li>
              </ul>
            </div>
            <!-- end health -->
          </li>
          <li><a href="insurance.html" title="Insurance Page">insurance</a>
            <!-- begin insurance -->
            <div id="insurance">
              <!-- property insurance -->
              <h2><a href="insurance/propertyinsurance1.html">home&frasl;property insurance</a></h2>
              <ul>
                <li><a href="insurance/usinsurancepropertyreview1.html">USInsuranceOnline.com &ndash; Property</a></li>
              </ul>
              <!-- auto insurance -->
              <h2><a href="insurance/autoinsurance1.html">auto insurance</a></h2>
              <ul>
                <li><a href="insurance/bestquotesautoreview1.html">BestQuotes.com</a></li>
                <li><a href="insurance/insuremycar4lessreview1.html">InsureMyCar4Less</a></li>
                <li><a href="insurance/lowermycarinsuranceratereview1.html">Lower My Car Insurance Rate</a></li>
                <li><a href="insurance/atlascarinsurancereview1.html">Atlas Car Insurance</a></li>
                <li><a href="insurance/insurancecomparisonreview1.html">Insurance Comparison</a></li>
              </ul>
              <!-- health insurance -->
              <h2><a href="insurance/healthinsurance1.html">health insurance</a></h2>
              <ul>
                <li><a href="insurance/betterhealthquotereview1.html">Better Health Quote</a></li>
                <li><a href="insurance/healthinsurancesourcesreview1.html">Health Insurance Sources</a></li>
                <li><a href="insurance/americanhealthcarecenterreview1.html">American Health Care Center Review</a></li>
                <li><a href="insurance/bestquoteshealthreview1.html">BestQuotes.com &ndash; Health</a></li>
              </ul>
              <!-- life insurance -->
              <h2><a href="insurance/lifeinsurance1.html">life insurance</a></h2>
              <ul>
                <li><a href="insurance/americaninsurancereview1.html">American Insurance</a></li>
                <li><a href="insurance/usinsurancelife1.html">USInsuranceOnline.com &ndash; Life</a></li>
              </ul>
            </div>
            <!-- end insurance -->
          </li>
          <li><a href="general.html" title="General Page">general</a>
          	<!-- begin general -->
            <div id="general">
              <!-- electronics -->
              <h2>electronics</h2>
                  <!-- gaming -->
                  <h3><span>gaming</span></h3>
                  <ul>
                    <li><a href="gaming/haltgamereview1.html">Halt Game</a></li>
                    <li><a href="gaming/battlestargalactica1.html">Battlestar Galactica</a></li>
                    <li><a href="gaming/gsn1.html">GSN Gaming</a></li>
                  </ul>
                  <!-- electronic gadgets -->
                  <h3><span>electronic gadgets</span></h3>
                  <ul>
                    <li><a href="electronics/kindle1.html">Kindle e&ndash;Reader</a></li>
                    <li><a href="electronics/ecig1.html">Electronic Cigarettes</a></li>
                  </ul>
              <!-- style and fashion -->
              <h2>style &amp; fashion</h2>
              	  <!-- makeup -->
                  <h3><span>makeup</span></h3>
                  <ul>
                    <li><a href="makeup/dinair1.html">Dinair Airbrush Makeup</a></li>
                    <li><a href="makeup/simplykaren1.html">Simply Karen</a></li>
                  </ul>
              <!-- food/dining -->
              <h2>food&frasl;dining</h2>
              	  <!-- net grocers -->
                  <h3><span>net grocers</span></h3>
                  <ul>
                    <li><a href="food/efooddepot1.html">eFood Depot</a></li>
                    <li><a href="food/peapod1.html">Peapod</a></li>
                  </ul>
                  <!-- coupons -->
                  <h3><span>coupons</span></h3>
                  <ul>
                    <li><a href="coupons/brandcaster1.html">Brandcaster Coupons</a></li>
                  </ul>
              <!-- cars/auto -->
              <h2>cars&frasl;auto</h2>
              <ul>
                <li><a href="auto/carfax1.html">Carfax Vehicle History Reports</a></li>
                <li><a href="auto/carprices1.html">CarPrices.com</a></li>
              </ul>
              <!-- security -->
              <h2>security</h2>
              <ul>
                <li><a href="security/adtalarm1.html">ADT Alarm System</a></li>
              </ul>
              <!-- hobby -->
              <h2>hobby</h2>
              	  <!-- music -->
                  <h3><span>music</span></h3>
                  <ul>
                    <li><a href="music/guitartricksreview1.html">GuitarTricks</a></li>
                    <li><a href="music/jamoramareview1.html">Jamorama&ndash; Learn Guitar</a></li>
                  </ul>
            </div>
            <!-- end general -->
          </li>
          <li><a href="dating.html" title="Dating Page">dating</a>
            <!-- begin dating -->
            <div id="dating">
            <!-- dating sites -->
            <h2>dating sites</h2>
              <ul>
                <li><a href="dating/realmaturesingles1.html">RealMatureSingles</a></li>
                <li><a href="dating/seniorpeoplemeet1.html">SeniorPeopleMeet</a></li>
                <li><a href="dating/adultfriendfinder1.html">Adult Friend Finder</a></li>
                <li><a href="dating/benaughty1.html">BeNaughty.com</a></li>
                <li><a href="dating/untrue1.html">Untrue.com</a></li>
                <li><a href="dating/elitemate1.html">EliteMate</a></li>
                <li><a href="dating/pridedating1.html">Pride Dating (gay)</a></li>
                <li><a href="dating/speeddate1.html">SpeedDate.com</a></li>
              </ul>
             <!-- books and advice -->
             <h2>books &amp; advice</h2>
               <ul>
               	 <li><a href="dating/askapril1.html">Ask April</a></li>
                 <li><a href="dating/bounceback1.html">Bounce Back to Dating Formula</a></li>
                 <li><a href="dating/datingsecrets1.html">Dating Secrets</a></li>
               </ul>
            </div>
            <!-- end dating -->
          </li>
          <li><a href="education.html" title="Education Page">education</a>
            <!-- begin education -->
            <div id="education">
              <ul>
                <li><a href="education/scholzone1.html">Scholarship Zone</a></li>
                <li><a href="education/speedstudytechniques1.html">Speed Study Techniques</a></li>
                <li><a href="education/stimulusgrants1.html">Stimulus Grants</a></li>
                <li><a href="education/teachmetoday1.html">Teach Me Today</a></li>
                <li><a href="education/winningsurveys1.html">Winning Surveys</a></li>
                <li><a href="education/basicskillsassessments1.html">Basic Skills Assessments</a></li>
              </ul>
            </div>
            <!-- end education -->
          </li>
          <li><a href="legal.html" title="Legal Page">legal</a>
            <!-- begin personal legal -->
            <div id="pLegal">
            <ul>
              <li><a href="debt/urgenthomerelief1.html">Urgent Home Relief</a></li>
            </ul>
            <!-- mortgage -->
            <h2>mortgage</h2>
            <ul>
              <li><a href="mortgage/foreclosurefighter1.html">Home Foreclosure Fighter</a></li>
              <li><a href="mortgage/fastcash4homes1.html">Fast Cash 4 Homes</a></li>
            </ul>
            <!-- debt -->
            <h2>debt</h2>
            	<!-- bankruptcy -->
                <h3><span><a href="legal/bankruptcy1.html">bankruptcy</a></span></h3>
                <ul>
                  <li><a href="debt/evalbankruptcy1.html">Bankruptcy Lawyer Finder</a></li>
                  <li><a href="legal/bankruptcy1.html">Bankruptcy Attorney Finder</a></li>
                </ul>
                <!-- credit debt -->
                <h3><span><a href="legal/creditdebt1.html">credit debt</a></span></h3>
            <ul>
              <li><a href="debt/debtnegotiator1.html">Debt Negotiator</a></li>
            </ul>
            <!-- divorce -->
            <h2>divorce</h2>
            <ul>
              <li><a href="legal/divorcedocuments1.html">Divorce Documents</a></li>
            </ul>
            <!-- defense attorney -->
            <h2>defense attorney</h2>
            <ul>
              <li><a href="legal/DUIattorney1.html">DUI Attorney</a></li>
            </ul>
            <!-- will creation -->
            <h2>will creation</h2>
            <ul>
              <li><a href="legal/willcreation1.html">Create My Will</a></li>
            </ul>
            </div>
            <!-- end personal legal -->
          </li>
        </ul>
</li>
        <!-- end Personal navigation menu-->
        <!-- begin Business navigation menu-->
        <ul id="bMenu">
          <li><a href="startyourownbusiness.html" title="Business Opportunities Page">business opportunities</a>
            <!-- business opportunities -->
            <div id="bizopps">
              <ul>
                <li><a href="bizopps/mobilemassmoney1.html">Mobile Mass Money</a></li>
                <li><a href="bizopps/autopilothomeprofits.html">Autopilot Home Profits</a></li>
                <li><a href="bizopps/anthonymorrison1.html">Anthony Morrison&apos;s Big Profits Secret</a></li>
              </ul>
              <!-- home business scams -->
              <h2>home business scams</h2>
              <ul>
              	<li><a href="bizopps/medicalbillinghomebusiness1.html">The Medical Billing Home Business Bible</a></li>
              </ul>
              <!-- medical -->
              <h2>medical</h2>
              <ul>
                <li><a href="bizopps/freesitesignup1.html">Cash&ndash;Pulling Affiliate Marketing Websites</a></li>
                <li><a href="bizopps/biggerbloggingprofitsreview1.html">Bigger Blogging Profits</a></li>
              </ul>
              <!-- affiliate marketing -->
              <h2>affiliate marketing</h2>
              <ul>
                <li><a href="bizopps/milliondollarpips1.html">Pips Forex Trading Robot</a></li>
                <li><a href="bizopps/pennystockprophet1.html">The Penny Stock Prophet</a></li>
              </ul>
              <!-- trading/investing -->
              <h2>trading&frasl;investing</h2>
              <ul>
                <li><a href="bizopps/swagbucks1.html">Swag Bucks</a></li>
              	<li><a href="bizopps/corsentialsurvey1.html">Corsential</a></li>
              </ul>
              <h2><a href="bizopps/makemoneywithsurveys1.html">surveys</a></h2>
              <ul>
              	<li><a href="bizopps/thepeoplesprogram1.html">The People&apos;s Program</a></li>
              </ul>
            </div>
            <!-- end business opportunities -->
          </li>
          <li><a href="businessservices.html" title="Business Services Page">business services</a></li>
          	<!-- business services -->
            <div id="bizservices">
              <ul>
              	<li><a href="bizopps/lessthantruckloadshipping1.html">Top Flight Concepts</a></li>
              </ul>
              <!-- shipping solutions -->
              <h2>shipping solutions</h2>
              <ul>
                <li><a href="telecommasterquoteagency1.html">Telecom Master Quote Agency</a></li>
              </ul>
              <!-- technology solutions -->
              <h2>technology solutions</h2>
              <ul>
                <li><a href="bizservices/projmgmttemplates1.html">Project Management Templates</a></li>
              </ul>
              <!-- project management -->
              <h2>project management</h2>
            </div>
            <!-- end business services -->
          </li>
          <li><a href="legal.html" title="Legal Services Page">legal services</a>
            <!-- begin business legal -->
            <div id="bLegal">
                <ul>
                  <li><a href="legal/willcreation1.html">Create My Will</a></li>
                </ul>
            <!-- will creation -->
            <h2>will creation</h2>
                <ul>
                  <li><a href="legal/DUIattorney1.html">DUI Attorney</a></li>
                </ul>
            <!-- defense attorney -->
            <h2>defense attorney</h2>
                <ul>
                  <li><a href="legal/divorcedocuments1.html">Divorce Documents</a></li>
                </ul>
            <!-- divorce -->
            <h2>divorce</h2>
                <ul>
                  <li><a href="debt/debtnegotiator1.html">Debt Negotiator</a></li>
                </ul>
                <!-- credit debt -->
                <h3><span><a href="legal/creditdebt1.html">credit debt</a></span></h3>
                    <ul>
                      <li><a href="debt/evalbankruptcy1.html">Bankruptcy Lawyer Finder</a></li>
                      <li><a href="legal/bankruptcy1.html">Bankruptcy Attorney Finder</a></li>
                    </ul>
                <!-- bankruptcy -->
                <h3><span><a href="legal/bankruptcy1.html">bankruptcy</a></span></h3>
            <!-- debt -->
            <h2>debt</h2>
                <ul>
                  <li><a href="mortgage/foreclosurefighter1.html">Home Foreclosure Fighter</a></li>
                  <li><a href="mortgage/fastcash4homes1.html">Fast Cash 4 Homes</a></li>
                </ul>
            <!-- mortgage -->
            <h2>mortgage</h2>
                <ul>
                  <li><a href="debt/urgenthomerelief1.html">Urgent Home Relief</a></li>
                </ul>
            </div>
            <!-- end business legal -->
          </li>
        </ul>
        <!-- end Business navigation menu-->
      </div>
      <!-- end wrapping div -->
    </div>
    <!-- end body div -->
    <div id="footer">&nbsp;</div>
    <!-- end footer div -->
    <h3 id="copytagatbottom">&copy;WorldReviewGroup.com<br />
      Updated Dec 14, 2012</h3>
  </div>
  <!-- end middle div -->

	<!-- begin side windows -->
  <div id="leftside">
    <div id="leftsideend">&nbsp;</div>
    <div id="leftsidebody">
      <h2 class="sideWindowHeaderText">Most Popular</h2>
      <ul class="sideWindowLinks">
        <li><a href="food/peapod1.html">Peapod</a></li>
        <li><a href="health/dieting/southbeach1.html">South Beach Diet</a></li>
        <li><a href="coupons/brandcaster1.html">Brandcaster Coupons</a></li>
      </ul>
    </div>
    <div id="leftsidestart">&nbsp;</div>
  </div><!-- end leftside div -->
  <div id="rightside"><!-- begin rightside div -->
    <div id="rightsidestart">&nbsp;</div>
    <div id="rightsidebody">
      <h2 class="sideWindowHeaderText">Not Recommended</h2>
      <ul class="sideWindowLinks">
        <li><a href="#">Anthony Morrison&apos;s Big Profits Secret</a></li>
        <li><a href="#">Mobile Mass Media</a></li>
        <li><a href="#">Prorexin</a></li>
      </ul>
      <form id="emailbox" name="form1" method="post" action="showwindow.html">
        <div>
          <input type="text" name="go" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
          <input type="submit" value="Join" onclick="postEmail()" />
        </div>
      </form>
      </div>
      <div id="rightsideend">&nbsp;</div>
  </div>
  <!-- end side windows -->
					<form name="form2" id="form2" method="post">
					  <label for="confirmemail">Confirm Your E-mail:<span>*</span></label>
					  <input type="text" name="confirmemail" value="" maxlength="60"/><br />
					  <label for="name">Enter Your Name:</label>
					  <input type="text" name="name" value="" maxlength="60" /><br />
					  <label for="age">Select Your Age Range:</label>
                      <select name="age">
                      	<option selected="selected">18&ndash;35</option>
                        <option>36&ndash;55</option>
                        <option>55+</option>
                        <option>17 or Younger</option>
                      </select>
					  <input type="text" name="age" value="" maxlength="3" /><br />
					  <label for="country">Select Your Country:<span>*</span></label>
					  <select name="country">
							 <option selected="selected">United States</option>
							 <option>United Kingdom</option>
							 <option>Canada</option>
							 <option>Australia</option>
							 <option>Russia</option>
							 <option>Brazil</option>
							 <option>Somewhere Else</option>
					   </select><br />
					   <input type="submit" value="Sign Me Up!" />
					</form>
			</div>
        </div><!-- end container -->
        </div><!-- end gray mask -->
	</body>
</html>

emailsubmit.css


@charset "utf-8";
/* CSS Document for the E-mail Submission Form */
#graymask{
	height:1000px;
	width:1360px;
	background:#999;
	opacity:40;
	filter:alpha(opacity=50);
	z-index:99;
}

#form2{
	background:url("emailsubmission.gif") no-repeat scroll 50% 0 transparent;
	width:360px;
	height:300px;
	margin-left:0;
	text-align:center;
	opacity:100;
	filter:alpha(opacity=100);
	z-index:999;
}
#form2 span{
	color:red;
}