thom22 0 Newbie Poster

Hi, i have been struggling for a while now trying to finish this, i am new to a lot of this and although i have had some tips i think i am getting myself more lost. So i have stripped the code to a point where it almost works.

DEMO IS HERE: http://designsbythom.com/meterread/test.html

I have a form a customer fills out to submit printer meter readings. Certain printer models have more than 1 reading, up to 3. When the customer clicks 'add printer' jQuery adds content and they select the model from a drop-down and the appropriate number or meter reading inputs appear. They then can click 'add printer' again for multiple printers.

The data is then posted to contact.php where it is validated and then sent by email in a readable format.

The problem i am getting is that i only get the first printer added and not the others. I think i need to use an input array but i don't know how exactly.

I currently get this in the email (only first printer displays):

>Meter Reading submitted by <b>Craig</b>. Account No. <b>123456</b>, readings are as follows.

>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>101010</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b> , Express Reading = .

>Customer <b>Craig</b> email, <b>Craig@craig.com</b>

--> Notice Express Reading is blank because it was needed. I deally this would not be there at all.

I would like it to come out something like this (when four printers added, two the same model):

>Meter Reading submitted by <b>Craig</b>. Account No. <b>123456</b>, readings are as follows.

>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>101010</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b>

>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>202020</b>. Mono Reading = <b>910</b>, Colour Reading = <b>1112</b>


>Printer Model = <b>ColorQube</b>, with Serial No. <b>303030</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b>, Express Reading = <b>91011</b> .

>Printer Model = <b>WorkCentre 7150</b>, with Serial No. <b>404040</b>. Mono Reading = <b>1234</b>

>Customer <b>Craig</b> email, <b>Craig@craig.com</b>

Below is the code for contact.php:

<?php

    if(!$_POST) exit;
 
		$name = $_POST['name'];
		$account = $_POST['account'];
        $email = $_POST['email'];
        $printer = $_POST['printer'];
		$serial = $_POST['serial'];
        $mono = $_POST['mono'];
		$colour = $_POST['colour'];
        $express = $_POST['express'];

		if(trim($name) == '') {
        	echo '<div class="error_message">Attention! You must enter your name.</div>';
			exit();
       		} else if(trim($email) == '') {
               	echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
       			exit();
          	} else if(!isEmail($email)) {
               	echo '<div class="error_message">Attention! You have entered an invalid e-mail address, try again.</div>';
		 		exit();
	    	}
		
        if($error == '') {
        
			if(get_magic_quotes_gpc()) {
            	$comments = stripslashes($comments);
            }

        // Configuration option.
        //$address = "example@example.net";
        $address = "somebody@email.com";
		
        // Example, $e_subject = '$name . ' has contacted you via Your Website.';
        $e_subject = 'Meter Reading submitted by - ' . $name . '. Account No.' . $account . '.';
        
        // Configuration option.
		$e_body = "Meter Reading submitted by $name. Account No. $account, readings are as follows.\r\n\n";
		
		// THIS NEEDS TO ONLY SHOW COLOUR AND EXPRESS READING IF THAT PRINTER REQUIRES IT - and - REPEAT FOR EACH ADDED PRINTER
		$e_content = "Printer Model = $printer, with Serial No. $serial. Mono Reading = $mono, Colour Reading = $colour , Express Reading = $express.\r\n\n";
		
		$e_reply = "Customer $name email, $email";
		   		
        $msg = $e_body . $e_content . $e_reply;
        
        if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) {
        
        
		// Email has sent successfully, echo a success page.
		
		echo "<fieldset>";			
		echo "<div id='success_page'>";
		echo "<h1>Email Sent Successfully.</h1>";
		echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
		echo "</div>";
		echo "</fieldset>";
				 
		} else {
		
		echo 'ERROR!';
		
		}
                      
	}

    function isEmail($email) { // Email address verification, do not edit.

    return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
		
    }
    ?>

I would be so grateful for some help with this. Please NOTE the linked file "<i>jquery.jigowatt.js</i>" as it also uses post.

I someone can help and sorry it is such a big one to explain and show. If you need any more info to help please let me know.

Thom