Jump to content

HTML forms


glennk

Recommended Posts

Im using this at the bottom of this page -

 

http://www.whitbyseaanglers.co.uk/kayak-launch-sites.php

 

Can someone in the know tell me where I went wrong. Ive never used submit forms before.

 

<form name="feedback" method="post" action="mailto:whitbyseaanglers@gmail.com">

<!-- Form elements will go in here -->

 

<p>Please enter the name of the launch site in the box below.</p>

<p><input name="mail" size="25" type="text"></p>

<p>Please tell us a bit about the launch site. Include such factors as parking, ease of launch etc. </p>

<p> <textarea cols="50" rows="10" name="comment"></textarea>

</p>

<p>Add a picture - If you don't have a picture don't worry, just skip this bit.</p><input type="file">

<p>Another picture if you have one.</p><input type="file">

 

<p><input value="Submit" type="submit">

<input type="reset"></p>

</form>

Link to comment
Share on other sites

unless I'm totally out of touch - and I could be - you generally have to pass the contents of a form to a processor of some description. Many hosts provide a form mail handler as standard.

 

I believe clook have a form generator as standard - which I would assume includes a form handler (a script to handle the processing and sending of the content parsed from the form).

 

HTH

Nick

 

 

...life

what's it all about...?

Link to comment
Share on other sites

Hi there. Nick's basically right - you need to put the address of a script that will process the form contents in the action attribute of the form element. You've currently got an email address, which will thoroughly confuse the browser as it trys to send an HTTP POST message with all your field contents to it.

 

If you want to do something with the contents of the form - such as email it to someone, then you need to write a script (in php or anything you like), or perhaps as Nick says use a third party script, that will take the field values that come through in the HTTP and put them into an email.

 

W

Link to comment
Share on other sites

Hi there. Nick's basically right - you need to put the address of a script that will process the form contents in the action attribute of the form element. You've currently got an email address, which will thoroughly confuse the browser as it trys to send an HTTP POST message with all your field contents to it.

 

If you want to do something with the contents of the form - such as email it to someone, then you need to write a script (in php or anything you like), or perhaps as Nick says use a third party script, that will take the field values that come through in the HTTP and put them into an email.

 

W

 

 

Cheers Guys,

 

Ill check it out at clook then :)

Link to comment
Share on other sites

I can`t guarantee this will work as its a quick 5 minute job, but it should be very very close :D

 

<?php//Set the maximum file size in bytes$max_file_size = 204800;// Set the max width in pixels$max_width = 800;// Set the max height in pixels$max_height = 600;// Set the directory to upload to// The form will upload to a directory of your choice on the server// It will also email you the uploaded image$directory_to_upload = "/dir/to/upload/to/";//Put unixtime in to a variable$time = time();if(isset($_POST['submit'])){	// MAKE THE POSTED TEXT SAFE (REMOVE/DISABLE XSS STUFF)	$mail = addslashes(strip_tags($_POST['mail']));	$comments = addslashes(strip_tags($_POST['comments']));	$image_dimensions = getimagesize($_FILES['image_to_upload']['tmp_name']);	$image_height = $image_dimensions[1];	$image_width = $image_dimensions[0];	$errors = array();		if(!$_FILES['image_to_upload']['name'])	{		$errors[] = "You did not select a file to upload.<br />";	}	if(!is_uploaded_file($_FILES['image_to_upload']['tmp_name']))	{		$errors[] = "Error while uploading file.<br />";	}	if($_FILES['image_to_upload']['size'] > $max_file_size)	{		$errors[] = "Your image size was too big. The maximum filesize is $mfs Kilobytes.<br />";	}	// Check the file is of the correct type	if(!$_FILES['image_to_upload']['tmp_name'] == 'image/jpeg' || 	!$_FILES['image_to_upload']['tmp_name'] == 'image/jpg' || 	!$_FILES['image_to_upload']['tmp_name'] == 'image/gif' || 	!$_FILES['image_to_upload']['tmp_name'] == 'image/png')	{		$errors[] = "Wrong file type, you can only upload .jpg, .gif and .png files.<br />";	}	// Check the image dimensions	if($image_height > $max_width)	{		$errors[] = "Your image height was too large.<br />";	}	if($image_width > $max_width)	{		$errors[] = "Your image width was too large.<br />";	}	if (!getimagesize($_FILES['image_to_upload']['tmp_name']))	{		$errors[] = "File is not a valid format. Valid file types are .jpg, .jpeg, .gif or .png.";	}		// If theres errors, show them, if not ignore this section	if(count($errors) > 0)	{		echo "<strong>Error:</strong> ";		foreach($errors as $err)		{			echo $err . "<br />";			exit();		}	}	else	{		// Rename the image to unixtime-temp_name		$image_url = $directory_to_upload . $time . '-' . $_FILES['image_to_upload']['name'];		// Rename the image to unixtime-ipaddress-name		$img_id = $time . '-' . $_FILES['image_to_upload']['name'];		// Copy the renamed file to the upload directory		if(copy($_FILES['image_to_upload']['tmp_name'], $directory_to_upload))		{			/**			 * 			 * ADD FILE TO THE EMAIL			 * 			 */						$filein = $_FILES['image_to_upload']['tmp_name'];						// Read the file to be attached ('rb' = read binary)			$file = fopen($filein,'rb');			$data = fread($file,filesize($filein));			fclose($file);			$semi_rand = md5($time);			$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";						// Add the headers for a file attachment			$headers .= "\nMIME-Version: 1.0\n" .			"Content-Type: multipart/mixed;\n" .			" boundary=\"{$mime_boundary}\"";						// Add a multipart boundary above the plain message			$message = "This is a multi-part message in MIME format.\n\n" .			"--{$mime_boundary}\n" .			"Content-Type: text/plain; charset=\"UTF-8\"\n" .			"Content-Transfer-Encoding: 7bit\n\n" .			$message . "\n\n";						// Base64 encode the file data			$data = chunk_split(base64_encode($data));						// Add file attachment to the message			$message .= "--{$mime_boundary}\n" .			"Content-Type: text-plain;\n" .			" name=\"{$filein}\"\n" .			"Content-Disposition: attachment;\n" .			" filename=\"{$filein}\"\n" .			"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" ."--{$mime_boundary}--\n";						//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//						/**			 * 			 * EDIT THESE FILEDS BELOW			 * 			 */												/**			 * 			 * ADD THE TEXT YOU WANT HERE			 * 			 */			//*****************************************************************************//			// ADD WHATEVER TEXT YOU WANT HERE			// ALWAYS USE $message .="your text here \n\n";			//*****************************************************************************//			$message = "INSERT MESSAGE HERE";			$message .= "From: $mail\n\n";			$message .= "Comments: $comments";						//*****************************************************************************//			// CHANGE TO YOUR EMAIL ADDRESS			//*****************************************************************************//			$to      = "mail@yourdomain.com";			//*****************************************************************************//			// EMAIL SUBJECT			//*****************************************************************************//			$subject = "EDIT SUBJECT HERE";			// EDIT THE HEADERS TO PUT A "FROM" ADDRESS, OR USE THE			// EXAMPLE BELOW TO HAVE THE SENDERS EMAIL AS THE FROM ADDRESS			// $headers = 'From: '.$mail.'' . "\r\n" . 'Reply-To: '.$mail.'' . "\r\n" . 'X-Mailer: PHP/' . phpversion();			$headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();						//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//			//*****************************************************************************//						if(mail($to, $subject, $message, $headers))			{				echo 'Thank You, the message was sent.';			}			else			{				echo 'Sorry, but there was an error sending your message, please try again.';			}		}		else		{			echo 'Error uploading file.';		}	}}else{	echo '<form name="feedback" method="post" action="filename.php"><!-- Form elements will go in here --><p>Please enter the name of the launch site in the box below.</p><p><input name="mail" size="25" type="text"></p><p>Please tell us a bit about the launch site. Include such factors as parking, ease of launch etc. </p><p> <textarea cols="50" rows="10" name="comment"></textarea></p><p>Add a picture - If you don\'t have a picture don\'t worry, just skip this bit.</p><input name="image_to_upload" id="image_to_upload" type="file" size="40" /><p>Another picture if you have one.</p><input name="image_to_upload" id="image_to_upload" type="file" size="40" /><p><input value="Submit" type="submit">
<input type="reset"></p>
</form>';

}

?>

Link to comment
Share on other sites

Ahhhhhhh

 

too late. Thanks for doing it though Si :) :)

 

Wish I could knock something like that up in 2 minutes. I managed to get a script from clook which seems to work. Only trouble is it wont let me send images with the text.

Edited by glennk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We and our partners use cookies on our website to give you the most relevant experience by remembering your preferences, repeat visits and to show you personalised advertisements. By clicking “I Agree”, you consent to the use of ALL the cookies. However, you may visit Cookie Settings to provide a controlled consent.