Jump to content

PLEASE HELP WITH PHP FORM WITH VARIOUS FIELDS AND ATTACHMENT TO BE SENT


Daywalker8331

Recommended Posts

Hi,

 

I have written this code (well, got snippets from various places) and it does not seem to work.

 

The Subject and From fields are fine but nothing from the form and the attachment come thru.

 

Please visit http://www.huskey.co.za/give_up/giveup.html to see the form thats need to be processed.

 

PLEASE HELP. I DONT KNOW WHAT TO DO AND HOW FIX THIS ::

 

Included is the whole php code that is called from the HTMl file:

 

<?php #edited by Fluffy

 

$hus_name = $_POST['hus_name'];

$hus_breed = $_POST['hus_breed'];

$hus_gender = $_POST['hus_gender'];

$hus_age = $_POST['hus_age'];

$hus_coat = $_POST['hus_coat'];

$hus_eyes = $_POST['hus_eyes'];

$hus_personality = $_POST['hus_personality'];

$hus_kids = $_POST['hus_kids'];

$hus_small_dogs = $_POST['hus_small_dogs'];

$hus_cats = $_POST['hus_cats'];

$rb_sterilised = $_POST['rb_sterilised'];

$rb_chipped = $_POST['rb_chipped'];

$rb_vaccinated = $_POST['rb_vaccinated'];

$rb_noise = $_POST['rb_noise'];

$rb_medical = $_POST['rb_medical'];

$owner_name = $_POST['owner_name'];

$owner_address = $_POST['owner_address'];

$owner_postal = $_POST['owner_postal'];

$owner_cell = $_POST['owner_cell']);

$owner_tel_h = $_POST['owner_tel_h'];

$owner_tel_w = $_POST['owner_tel_w'];

$owner_fax = $_POST['owner_fax'];

$owner_email = $_POST['owner_email'];

$reason_giving_up = $_POST['reason_giving_up'];

$rb_agree = $_POST['rb_agree'];

$att = $_FILES['att'];

$att_path = $_FILES['att']['tmp_name'];

$att_name = $_FILES['att']['name'];

$att_size = $_FILES['att']['size'];

$att_type = $_FILES['att']['type'];

 

 

#open, read then close the file

$fp = fopen( $att_path, "rb");

$file = fread( $fp, $att_size );

fclose( $fp );

 

#create a boundary string

$num = md5(time());

$str = "==Multipart_Boundary_x{$num}x";

 

#encode the data for safe transit

#and intersperse 76-character chunks with \r\n

$file = chunk_split(base64_encode($file));

 

 

#define header

$header = "From: $owner_email\n";

$header .= "Reply-To: $owner_email\n";

$header .= "MIME-Version: 1.0\n";

$header .= "Content-Type: multipart/mixed;\n ";

$header .= "boundary=\"{$str}\"";

 

 

$subject = "Online Husky Release Request";

 

$email_to = "[email protected]";

 

#define message

$message = "Husky Name: $hus_name\n";

$message .= "Husky Breed: $hus_breed\n";

$message .= "Husky Gender: $hus_gender\n";

$message .= "Husky Age: $hus_age\n";

$message .= "Husky Coat Description: $hus_coat\n";

$message .= "husky Eyes Description: $hus_eyes\n";

$message .= "Husky Personality: $hus_personality\n";

$message .= "How is he with kids: $hus_kids\n";

$message .= "How is he with small dogs: $hus_small_dogs\n";

$message .= "How is he with cats: $hus_cats\n";

$message .= "Is he sterilized: $rb_sterilised\n";

$message .= "Is he chipped: $rb_chipped\n";

$message .= "Is he vaccinated: $rb_vaccinated\n";

$message .= "Does he have noise phobia: $rb_noise\n";

$message .= "Does he have a medical condition: $rb_medical\n";

$message .= "Owners name: $owner_name\n";

$message .= "Owners address: $owner_address\n";

$message .= "Owners postal: $owner_postal\n";

$message .= "Owners cell number: $owner_cell\n";

$message .= "Owners tel home number: $owner_tel_h\n";

$message .= "Owners tel work number: $owner_tel_w\n";

$message .= "Owners fax number: $owner_fax\n";

$message .= "Owners email address: $owner_email\n";

$message .= "Reason for giving up the Husky: $reason_giving_up\n";

$message .= "I, the current legal owner of the dog described above, hereby pass ownership of the dog in question over to Husky Rescue Southern Africa.\n";

$message .= "I undertake to hand my dog over to HRSA sterilized, vaccinated & micro-chipped.\n";

$message .= "I will hand the Vet Card over with the dog as proof that all the above was done.\n";

$message .= "Does the owner agree to the terms and conditions: $rb_agree\n";

$message .= "End of message";

 

#define the non-text attachment

$message .= "Content-Type: {$att_type};\n";

$message .= "name=\"{$att_name}\"\n";

$message .= "Content-Disposition: attachment;\n";

$message .= "filename=\"{$att_name}\"\n";

$message .= "Content-Transfer-Encoding: base64\n\n";

$message .= "$file\n\n";

$message .= "--{$str}";

 

@mail($email_to, $subject ,$message ,$header ) ;

 

header("Location: http://www.huskyrescue.co.za/"); /* Redirect browser */

 

/* Make sure that code below does not get executed when we redirect. */

exit;

 

 

//echo("<p align='center'><b><font face='Calibri' size='2' color='#000000'>Your request have been sent successfully.<br>A Husky Rescue Representative will be in contact with you soon.</font></b></p>");

?>

 

[attachment deleted by admin]

Daywalker8331,

 

I downloaded your giveup.html and posted code, and ran it through my trusty Zend Studio 5.5.0 IDE and all of the posted values were in $_POST.

 

Add:

 


<?php

    #-- Assignment : List arbitary number of name in an HTML table
    function listNames() {
	GLOBAL $table;
	$table = "<table border=\"1\"> \n";
	if (func_num_args() > 0) {
		$numOfArgs = func_num_args();

		for ($i=0; $i < $numOfArgs; $i++) {

			$table .= "  <tr> \n";
			$table .= "    <td>    \n";
			$table .= func_get_arg($i);
			$table .= "      </td> \n";
			$table .= "  </tr> \n";
		}
	}
	else {
		echo "No Args Passed" . " <br /> \n";
	}
	$table .= "</table> \n";
	return $table;
}

   #-- END Assignment : List arbitary number of name in an HTML table
   # -- printArray : List members in a array -- #
   
function printArray($arrayName, $name = false, $file=NULL, $line=NULL) {

	if ($file == NULL) {
		$file = '*** Not Specified ***';
	}

	if ($line == NULL) {
		$line = '*** Not Specified ***';
	}

	if ($name)  {
		echo "Name :: $name" . " :: Reporting from line :: " . $line .  " :: in program :: " . $file . " ::<br /> \n";
	}
	if (!is_array($arrayName)) {

		$saveArray = $arrayName;

		$arrayName = 'Not An Array';

		$possibleString = TRUE;
	}
	if (empty($arrayName)) {
		$arrayName = 'Array Contains No Data';
	}


	echo "<font color=\"#205E75\"> \n";
	echo "<pre> \n";

		print_r($arrayName);

	echo "</pre> \n";

	echo "</font> \n";

	if ($possibleString == TRUE) {

		$string = $saveArray;

		if ($string == NULL) {

			$string = 'Null String';
		}

		echo "<font color=\"#205E75\"> \n";
		echo " <br /> <br /> \n";
		echo '$array as string: ' . $string  . "<br /> <br /> \n";
		echo " <br /> <br /> \n";
		echo "</font> \n";

	}
}

function printArrayVarDump($arrayName, $name = false, $file=NULL, $line=NULL) {

	if ($file == NULL) {
		$file = '*** Not Specified ***';
	}

	if ($line == NULL) {
		$line = '*** Not Specified ***';
	}


	if ($name)  {
		echo "Name :: $name" . " :: Reporting from line :: " . $line .  " :: in program :: " . $file . " ::<br /> \n";
	}
	echo "<pre> \n";
		var_dump($arrayName);
	echo "</pre> \n";

	if ($possibleString == TRUE) {

		$string = $arrayName;

		if ($string == NULL) {

			$string = 'Null String';
		}

		echo '$array as string: ' . $string  . "<br /> <br /> \n";

	}
	// echo " <br /> <br /> \n";
}

function arrayPrint($arrayName, $name = false) {
	printArray($arrayName, $name = false);
}

?>

 

followed by:

 


<?php

$display = TRUE;

if ($display) {
    printArray($_POST, '$_POST', __FILE__, __LINE__);
    exit;
    
}

?>

 

to the top of emailparser.php and see what's generated...

 

Hope this helps.

 

Scot L. Diddle, Richmond VA

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.