1 |
<? |
2 |
include_once( "global.php" ); |
3 |
include_once( "dbconnect.php" ); |
4 |
include_once( "$phormationdir/form.php" ); |
5 |
include_once( "$phormationdir/file_upload.php" ); |
6 |
|
7 |
function html_before_form() |
8 |
{ |
9 |
?> |
10 |
<HTML> |
11 |
<HEAD> |
12 |
<link rel="stylesheet" type="text/css" href="styles.css"> |
13 |
</HEAD> |
14 |
<BODY bgcolor="#FFFFFF"> |
15 |
<? |
16 |
} |
17 |
function html_after_form() |
18 |
{ |
19 |
?> |
20 |
</BODY> |
21 |
</HTML> |
22 |
<? |
23 |
} |
24 |
|
25 |
// define the fields in the form |
26 |
$fields[] = "firstname"; |
27 |
$names[] = "First Name"; |
28 |
$types[]="type=text&width=20&length=50&required=1"; |
29 |
|
30 |
$fields[] = "lastname"; |
31 |
$names[] = "Last Name"; |
32 |
$types[]="type=text&width=20&length=50&required=1"; |
33 |
|
34 |
$fields[] = "phone"; |
35 |
$names[] = "Phone Number"; |
36 |
$types[]="type=phone"; |
37 |
|
38 |
$fields[] = "email"; |
39 |
$names[] = "Email Address"; |
40 |
$types[]="type=email&width=20&length=50"; |
41 |
|
42 |
$fields[] = "typeid"; |
43 |
$names[] = "Type"; |
44 |
$types[]="type=select&map[P]=Personal&map[B]=Business&selecttype=dropdown"; |
45 |
|
46 |
$fields[] = "notes"; |
47 |
$names[] = "Notes"; |
48 |
$types[]="type=text&height=5&width=40&length=5000"; |
49 |
|
50 |
$fields[] = "photo,origphoto"; |
51 |
$names[] = "Photo"; |
52 |
$types[]="type=file&process_hook=default_image_process_hook&processparm=photoseq&targetdir=/home/jdhildeb/public_html/phexample/pics&showfilename=1&imagemode=1&serverdir=pics"; |
53 |
|
54 |
$opts = array(); |
55 |
$opts["delete_hook"] = "my_delete_fcn"; |
56 |
$url = array(); |
57 |
$url["home"] = "contact_index.php"; |
58 |
|
59 |
function my_delete_fcn( $tablename, $tablekey, $record_id ) |
60 |
{ |
61 |
// since we also have to delete a photo when we delete this record, |
62 |
// we write a short function to do this. We pass the name of this function |
63 |
// to Phormation in the "opts" array, so that it will call this |
64 |
// function instead of its own function for deleting the record |
65 |
$query = "select photo from contact where id = $record_id"; |
66 |
$result = pg_exec( $query ); |
67 |
if( $result ) { |
68 |
$array = pg_fetch_array( $result, 0 ); |
69 |
$filename = "/home/jdhildeb/public_html/phexample/pics/" . trim( $array[0] ); |
70 |
@unlink( $filename ); |
71 |
} |
72 |
|
73 |
// now we call phormation's delete function to delete the database |
74 |
// record |
75 |
deleterecord( $tablename, $tablekey, $record_id ); |
76 |
} |
77 |
|
78 |
form_main( "contact", "id", $fields, $names, $types, $record_id, $url, $opts ); |
79 |
?> |