Computers |
|
| | #1 (permalink) |
| Newb Techie Join Date: Jan 2006
Posts: 1
| Hi, My search engine can't work even after i had insert the php codes. My Search Fields are: Subject ID, Subject Name, Type of Document, Option, Year, and Creator My codes are below: <html> 22 <head> 23 <meta http-equiv="Content-Language" content="en-us"> 24 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 25 <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> 26 <meta name="ProgId" content="FrontPage.Editor.Document"> 27 <title>Edit Database form</title> 28 </head> 29 <body topmargin="0" leftmargin="0" style="font-family: Verdana; font-size: 8pt"> 30 <? 31 session_start(); 32 if($_SESSION['username']=="" || $_SESSION['passwd']=="") 33 { 34 header("Location: index.html"); 35 die(); 36 } 37 else 38 { 39 if(!isset($_POST['operation'])) //If no button was clicked... 40 { 41 //display form for the first time 42 echo "<div align='center'>"; 43 echo "<center>"; 44 echo "<table border='0' width='836'>"; 45 echo "<tr>"; 46 echo "<td width='850' colspan='3'>[img]images/logo.gif[/img]</td>"; 47 echo "</tr>"; 48 echo "<tr>"; 49 echo "<td width='127' bgcolor='#EEEEEE'>[img]images/left.gif[/img]</td>"; 50 echo "<td width='540' bgcolor='#EEEEEE'>"; 51 echo "<table border='1' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 52 echo "<tr>"; 53 echo "<td width='50%' align='center'>Enquiries</td>"; 54 echo "<td width='50%' align='center'>Clients</td>"; 55 echo "</tr>"; 56 echo "<tr>"; 57 echo "<td width='50%' align='center'>"; 58 echo "<table border='0' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 59 echo "<tr>"; 60 echo "<td width='25%' align='center'><font size='2'>Add</font></td>"; 61 echo "<td width='25%' align='center'><font color='#000080' size='2'>Edit</font></td>"; 62 echo "<td width='25%' align='center'><font color='#000080' size='2'>Delete</font></td>"; 63 echo "<td width='25%' align='center'><font color='#000080' size='2'>List</font></td>"; 64 echo "</tr>"; 65 echo "</table>"; 66 echo "</td>"; 67 echo "<td width='50%' align='center'>"; 68 echo "<table border='0' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 69 echo "<tr>"; 70 echo "<td width='25%' align='center'><font color='#000080' size='2'>Add</font></td>"; 71 echo "<td width='25%' align='center'><font color='#000080' size='2'>Edit</font></td>"; 72 echo "<td width='25%' align='center'><font color='#000080' size='2'>Delete</font></td>"; 73 echo "<td width='25%' align='center'><font color='#000080' size='2'>List</font></td>"; 74 echo "</tr>"; 75 echo "</table>"; 76 echo "</td>"; 77 echo "</tr>"; 78 echo "</table>"; 79 echo "</td>"; 80 echo "<td width='171' bgcolor='#EEEEEE'>"; 81 echo "<p align='right'>[img]images/right.gif[/img]</td>"; 82 echo "</tr>"; 83 echo "<tr>"; 84 echo "<td width='127' bgcolor='#EEEEEE' valign='top'>[img]images/glass0873_small.jpg[/img]"; 85 echo " <font face='Verdana' size='2' color='#FF0000'>ConsNET</font></p>"; 86 echo " </td>"; 87 echo "<td width='540' bgcolor='#EEEEEE' valign='top'>"; 88 $action=$_SERVER['PHP_SELF']; 89 echo "<form method='POST' action='$action'>"; 90 echo "<table border='0' width='100%' style='font-family: Verdana; font-size: 8pt; font-weight: bold'>"; 91 echo "<tr>"; 92 echo "<td width='37%' valign='top'>Name</td>"; 93 echo "<td width='63%' valign='top'><input type='text' name='name' size='43' style='font-family: Verdana; font-size: 8pt'></td>"; 94 echo "</tr>"; 95 echo "<tr>"; 96 echo "<td width='37%' valign='top'>Address</td>"; 97 echo "<td width='63%' valign='top'><textarea rows='3' name='address' cols='41' style='font-family: Verdana; font-size: 8pt'></textarea></td>"; 98 echo "</tr>"; 99 echo "<tr>"; 100 echo "<td width='37%' valign='top'>Enquiry Date</td>"; 101 echo "<td width='63%' valign='top'><input type='text' name='enquiry_date' size='23' style='font-family: Verdana; font-size: 8pt' value='yyyy-mm-dd'></td>"; 102 echo "</tr>"; 103 echo "<tr>"; 104 echo "<td width='37%' valign='top'>Phone (Res)</td>"; 105 echo "<td width='63%' valign='top'><input type='text' name='res_phone' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 106 echo "</tr>"; 107 echo "<tr>"; 108 echo "<td width='37%' valign='top'>Phone (Off)</td>"; 109 echo "<td width='63%' valign='top'><input type='text' name='off_phone' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 110 echo "</tr>"; 111 echo "<tr>"; 112 echo "<td width='37%' valign='top'>Fax</td>"; 113 echo "<td width='63%' valign='top'><input type='text' name='fax' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 114 echo "</tr>"; 115 echo "<tr>"; 116 echo "<td width='37%' valign='top'>Email</td>"; 117 echo "<td width='63%' valign='top'><input type='text' name='email' size='43' style='font-family: Verdana; font-size: 8pt'></td>"; 118 echo "</tr>"; 119 echo "<tr>"; 120 echo "<td width='37%' valign='top'>Type of Accommodation</td>"; 121 echo "<td width='63%' valign='top'><input type='text' name='accomodation_type' size='22' style='font-family: Verdana; font-size: 8pt'></td>"; 122 echo "</tr>"; 123 echo "<tr>"; 124 echo "<td width='37%' valign='top'>Budget (in lacs)</td>"; 125 echo "<td width='63%' valign='top'><input type='text' name='budget' size='22' style='font-family: Verdana; font-size: 8pt'></td>"; 126 echo "</tr>"; 127 echo "<tr>"; 128 echo "<td width='37%' valign='top'>Housing Finance</td>"; 129 echo "<td width='63%' valign='top'><select size='1' name='housing_finance' style='font-family: Verdana; font-size: 8pt'>"; 130 echo "<option>Y</option>"; 131 echo "<option>N</option>"; 132 echo "<option>U</option>"; 133 echo "</select></td>"; 134 echo "</tr>"; 135 echo "<tr>"; 136 echo "<td width='37%' valign='top'>Preferred Location</td>"; 137 echo "<td width='63%' valign='top'><input type='text' name='preferred_location' size='22' style='font-family: Verdana; font-size: 8pt'></td>"; 138 echo "</tr>"; 139 echo "<tr>"; 140 echo "<td width='37%' valign='top'>Remarks</td>"; 141 echo "<td width='63%' valign='top'><textarea rows='3' name='remarks' cols='41' style='font-family: Verdana; font-size: 8pt'></textarea></td>"; 142 echo "</tr>"; 143 echo "<tr>"; 144 echo "<td width='37%' valign='top'></td>"; 145 echo "<td width='63%' valign='top'><input type='radio' value='1' name='operation'>Search"; 146 echo "Record <input type='radio' name='operation' value='2' style='font-family: Verdana; font-size: 8pt'>Update"; 147 echo "Changes</td>"; 148 echo "</tr>"; 149 echo "</table>"; 150 echo "<p align='center'><input type='submit' value='Perform the Selected Operation' name='search' style='font-family: Verdana; font-size: 8pt'></p>"; 151 echo "</form>"; 152 echo " "; 153 echo "</td>"; 154 echo "<td width='171' bgcolor='#EEEEEE' valign='top'></td>"; 155 echo "</tr>"; 156 echo "</table>"; 157 echo "</center>"; 158 echo "</div>"; 159 } 160 elseif ($_POST['operation']=="1") 161 { 162 //insert code to display information form the database here 163 include('db.php'); //db.php contains code to open the database and establich a connection to the mySQL database 164 if ($_POST['name']=="") 165 { 166 $enq_name==""; 167 } 168 else 169 { 170 $enq_name=$_POST['name']; 171 } 172 $qry=mysql_query("SELECT * FROM prospects WHERE name = '$enq_name'") or die ("Error in query: " .mysql_error()); 173 $row= mysql_num_rows($qry); 174 if ($row==0) 175 { 176 //if no matching records are found in the database send user back to the page he came from (here its the same page) 177 //the javascript does not seem to work here, dunno why 178 header("Location: edit_enquiry.php"); 179 echo("<script language="JavaScript">\n"); 180 echo("<!--\n"); 181 echo("alert(\"No records were found that match your query.\n\")"); 182 echo("//-->\n"); 183 echo("</script>"); 184 } 185 else 186 { 187 //get the query results into an associative array so that we can reference array items using names 188 $result_array=mysql_fetch_array($qry,MYSQL_ASSOC); 189 //Get database values into page variables 190 $enq_id = $result_array['id']; 191 $enq_address=$result_array['address']; 192 $enq_date=$result_array['enquiry_date']; 193 $enq_residence_phone=$result_array['residence_phone']; 194 $enq_office_phone=$result_array['office_phone']; 195 $enq_fax=$result_array['fax']; 196 $enq_email=$result_array['email']; 197 $enq_type=$result_array['type_of_accomodation']; 198 $enq_budget=$result_array['budget']; 199 $enq_loan=$result_array['loan_facility']; 200 $enq_location=$result_array['preffered_location']; 201 $enq_remarks=$result_array['remarks']; 202 } 203 echo "<div align='center'>"; 204 echo "<center>"; 205 echo "<table border='0' width='836'>"; 206 echo "<tr>"; 207 echo "<td width='850' colspan='3'>[img]images/logo.gif[/img]</td>"; 208 echo "</tr>"; 209 echo "<tr>"; 210 echo "<td width='127' bgcolor='#EEEEEE'>[img]images/left.gif[/img]</td>"; 211 echo "<td width='540' bgcolor='#EEEEEE'>"; 212 echo "<table border='1' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 213 echo "<tr>"; 214 echo "<td width='50%' align='center'>Enquiries</td>"; 215 echo "<td width='50%' align='center'>Clients</td>"; 216 echo "</tr>"; 217 echo "<tr>"; 218 echo "<td width='50%' align='center'>"; 219 echo "<table border='0' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 220 echo "<tr>"; 221 echo "<td width='25%' align='center'><font size='2'>Add</font></td>"; 222 echo "<td width='25%' align='center'><font color='#000080' size='2'>Edit</font></td>"; 223 echo "<td width='25%' align='center'><font color='#000080' size='2'>Delete</font></td>"; 224 echo "<td width='25%' align='center'><font color='#000080' size='2'>List</font></td>"; 225 echo "</tr>"; 226 echo "</table>"; 227 echo "</td>"; 228 echo "<td width='50%' align='center'>"; 229 echo "<table border='0' width='100%' bordercolor='#000000' style='font-family: Verdana; font-size: 8pt'>"; 230 echo "<tr>"; 231 echo "<td width='25%' align='center'><font color='#000080' size='2'>Add</font></td>"; 232 echo "<td width='25%' align='center'><font color='#000080' size='2'>Edit</font></td>"; 233 echo "<td width='25%' align='center'><font color='#000080' size='2'>Delete</font></td>"; 234 echo "<td width='25%' align='center'><font color='#000080' size='2'>List</font></td>"; 235 echo "</tr>"; 236 echo "</table>"; 237 echo "</td>"; 238 echo "</tr>"; 239 echo "</table>"; 240 echo "</td>"; 241 echo "<td width='171' bgcolor='#EEEEEE'>"; 242 echo "<p align='right'>[img]images/right.gif[/img]</td>"; 243 echo "</tr>"; 244 echo "<tr>"; 245 echo "<td width='127' bgcolor='#EEEEEE' valign='top'>[img]images/glass0873_small.jpg[/img]"; 246 echo " <font face='Verdana' size='2' color='#FF0000'>ConsNET</font></p>"; 247 echo " </td>"; 248 echo "<td width='540' bgcolor='#EEEEEE' valign='top'>"; 249 $action=$_SERVER['PHP_SELF']; 250 echo "<form method='POST' action='$action'>"; 251 echo "<table border='0' width='100%' style='font-family: Verdana; font-size: 8pt; font-weight: bold'>"; 252 echo "<tr>"; 253 echo "<td width='37%' valign='top'>Name</td>"; 254 echo "<td width='63%' valign='top'><input type='text' name='name' size='43' value = '$enq_name' style='font-family: Verdana; font-size: 8pt'></td>"; 255 echo "</tr>"; 256 echo "<tr>"; 257 echo "<td width='37%' valign='top'>Address</td>"; 258 echo "<td width='63%' valign='top'><textarea rows='3' name='address' cols='41' style='font-family: Verdana; font-size: 8pt'>$enq_address</textarea></td>"; 259 echo "</tr>"; 260 echo "<tr>"; 261 echo "<td width='37%' valign='top'>Enquiry Date</td>"; 262 echo "<td width='63%' valign='top'><input type='text' name='enquiry_date' value = '$enq_date' size='23' style='font-family: Verdana; font-size: 8pt' value='yyyy-mm-dd'></td>"; 263 echo "</tr>"; 264 echo "<tr>"; 265 echo "<td width='37%' valign='top'>Phone (Res)</td>"; 266 echo "<td width='63%' valign='top'><input type='text' name='res_phone' value = '$enq_residence_phone' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 267 echo "</tr>"; 268 echo "<tr>"; 269 echo "<td width='37%' valign='top'>Phone (Off)</td>"; 270 echo "<td width='63%' valign='top'><input type='text' name='off_phone' value = '$enq_office_phone' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 271 echo "</tr>"; 272 echo "<tr>"; 273 echo "<td width='37%' valign='top'>Fax</td>"; 274 echo "<td width='63%' valign='top'><input type='text' name='fax' value = '$enq_fax' size='23' style='font-family: Verdana; font-size: 8pt'></td>"; 275 echo "</tr>"; 276 echo "<tr>"; 277 echo "<td width='37%' valign='top'>Email</td>"; 278 echo "<td width='63%' valign='top'><input type='text' name='email' value='$enq_email' size='43' style='font-family: Verdana; font-size: 8pt'></td>"; 279 echo "</tr>"; 280 echo "<tr>"; 281 echo "<td width='37%' valign='top'>Type of Accommodation</td>"; 282 echo "<td width='63%' valign='top'><input type='text' name='accomodation_type' value= '$enq_type' size='22' style='font-family: Verdana; font-size: 8pt'></td>"; 283 echo "</tr>"; 284 echo "<tr>"; 285 echo "<td width='37%' valign='top'>Budget (in lacs)</td>"; 286 echo "<td width='63%' valign='top'><input type='text' name='budget' value = '$enq_budget' size='22' style='font-family: Verdana; font-size: 8pt'></td>"; 287 echo "</tr>"; 288 echo "<tr>"; 289 echo "<td width='37%' valign='top'>Housing Finance</td>"; 290 echo "<td width='63%' valign='top'><select size='1' name='housing_finance' style='font-family: Verdana; font-size: 8pt'>"; 291 echo "<option>Y</option>"; 292 echo "<option>N</option>"; 293 echo "<option>U</option>"; 294 echo "</select></td>"; 295 echo "<tr>"; 296 echo "<td width='37%' valign='top'>Preferred Location</td>"; 297 echo "<td width='63%' valign='top'><input type='text' name='preferred_location' size='22' value = '$enq_location' style='font-family: Verdana; font-size: 8pt'></td>"; 298 echo "</tr>"; 299 echo "<tr>"; 300 echo "<td width='37%' valign='top'>Remarks</td>"; 301 echo "<td width='63%' valign='top'><textarea rows='3' name='remarks' cols='41' style='font-family: Verdana; font-size: 8pt'>$enq_remarks</textarea></td>"; 302 echo "</tr>"; 303 echo "<tr>"; 304 echo "<td width='37%' valign='top'></td>"; 305 echo "<td width='63%' valign='top'><input type='radio' value='1' name='operation'>Search"; 306 echo "Record <input type='radio' name='operation' value='2' style='font-family: Verdana; font-size: 8pt'>Update"; 307 echo "Changes</td>"; 308 echo "</tr>"; 309 echo "</table>"; 310 echo "<p align='center'><input type='submit' value='Perform the Selected Operation' name='search' style='font-family: Verdana; font-size: 8pt'></p>"; 311 echo "</form>"; 312 echo " "; 313 echo "</td>"; 314 echo "<td width='171' bgcolor='#EEEEEE' valign='top'></td>"; 315 echo "</tr>"; 316 echo "</table>"; 317 echo "</center>"; 318 echo "</div>"; 319 } 320 elseif($_POST['operation']=="2") 321 { What has gone wrong with my codes? Please help me.. Deon |
| | |
| | #2 (permalink) |
| Dope Tech | can you please omit the line numbers and wrap it in code tags? what output do you get? what output do you expect?
__________________ Tech IMO.com | ExtremeTech.com | ASP Free.com | SysOpt.com | Tech Support Guy.org DB Forums.com | Cyber Tech Help.com | Lazy Forums.com | Warrior Nation.net 'If you don't stand for somethin you'll fall for anything' - Dr. Dre Been there, done that |
| | |