[thelist] php

Liam Delahunty liam at megaproducts.co.uk
Mon Mar 1 05:23:32 CST 2004


on 29/02/2004 19:52 Mohammed Ibrar wrote:

>  
> I need to create a email form for my website that will append text 
> to a php file using php. 
 > I have created the form and need help with the php code.
>  

// you need to name the submit button submit.
// define the $my_path to where your file is
// change $my_field as appropriate.

if ($submit){
	// what kind of checking can we do?
	// let's make sure it's not empty at least.
	if ($my_field == ""){
		$err_array[my_field] = "<b>Error</b> field is blank.";
	}

	if (count($err_array)!=0){
		// display errors
		print ("<p class=err>Please correct the error(s):<br>");
		while (list($index,$value) = each($err_array)){
			print ("$value<br>");
		}
		print ("</p>\n");
	}else{
		// add it damn you!

		// add line break too.
		$my_field .= "\n";

		$mp = fopen("$my_path", "a+");
		$did_it_work = (fwrite($mp, $my_field));
		if ($did_it_work) {
			print ("<p>The file has been updated.</p>");
		}else{
			print ("<p><b>Error.</b> ".__LINE__."</p>");
		}
		fclose($fp);
	}
}


-- 
Kind regards, Liam Delahunty, Mega Products Ltd
12 Bury Place, London WC1A 2JL Fax: +44(0)871 224 7891
http://www.megaproducts.co.uk/ Internet Design & Development


More information about the thelist mailing list