|
31-03-2009, 19:29
|
|
|
חבר מתאריך: 31.07.05
הודעות: 106
|
|
בעיה עם קידוד של PHP ו-HTML דרך AJAX
שלומות,
יש לי את הקטעי קוד הבאים [מצטער שחלק מהם צונזרו, זה אתר שבניתי לבסיס אז אני לא יכול להראות הכל]
הבעיה היא שה-AJAX שמחזיר את הקוד מחזיר לי ג'יבריש...
במקום שיהיה כתוב "משתנה בלה בלה" כתוב "?????????"
ועוד משהו , במקום שזה יעבד לי את הקוד המחוזר [הוא אמור להחזיר טבלאות , תסתכלו בקוד של דף "search.php"] והוא מחזיר לי קוד בלתי מעובד.
לדוג' : במקום שיראה טבלה הוא כותב לי
<div align="left">
<div align="right">הוא כאילו מחזיר לי קוד "גולמי"
הנה הקודים של הדפים:
קוד PHP:
<?php session_start(); include ("checker.php"); if (sessioncheck() == false) { setcookie("fail", "no login", time()+200); header("location:entrance.php"); } include("connector.php"); include("submenu.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html dir="rtl" lang="he"> <head> <META HTTP-*******"refresh" CONTENT="1800;URL=search_users.php"> <link href="style.css" rel="stylesheet" type="text/css" /> <title> חיפוש אחר משתמשים </title> <script language="javascript" type="text/javascript"> function poploader(){ var x = document.getElementById('button'); x.className = "buttonload"; } function killloader(){ var x = document.getElementById('button'); x.className = "button"; } function onMouse(){ //var x = document.getElementsByTagName('form'); //x['button'].style.background = "url(images/search_button2.gif)"; var x = document.getElementById('1'); x['button'].className = "button2"; } function onMouseout(){ //var x = document.getElementsByTagName('form'); //x['button'].style.background = "url(images/search_button.gif)"; var x = document.getElementById('1'); x['button'].className = "button"; } function ajaxFunction(){ var xmlHTTP; try{ xmlHTTP=new XMLHttpRequest(); } catch (e){ try{ xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("your browser aint supporting AJAX"); } } } var x = document.getElementById('1'); var check = 1; var id = document.getElementById('id').value; poploader(); var qstring = "?id=" + id + "&check=" + check; xmlHTTP.onreadystatechange = function(){ var check = 0;
if (xmlHTTP.readystate == 4 ){ killloader(x); var response = xmlHTTP.responseText; var ajaxDisplay = document.getElementById("ajaxResp"); var txt=document.createTextNode(response); ajaxDisplay.appendChild(txt); } } xmlHTTP.open("GET","search.php" + qstring,true); xmlHTTP.send(null); } </script> </head> <body> <div id='mainBody'> <div align="center"> <h2>חיפוש אחר בקשות משתמשים</h2> <h3>"s" שים לב ! אין לכתוב את המספר האישי עם האות</h3> </div> <?php if (isset($_SESSION['num'])){ unset($_SESSION['num']); echo "<h2>יש להזין ספרות בלבד</h2>"; } ?> <br><br><br> <table id="mainTable" cellpadding=1 border=1 width=8% align=center> <tr> <form id="1"> <td><input id="id" type="text" name="id" maxlength="7" onMouseOver='this.style.borderColor="#66CD00"' onMouseOut='this.style.borderColor="#494949"'></td> <td nowrap>הכנס xxxx לחיפוש</td> </tr> <tr> <td colspan="2"><input type='button' id='button' class='button' title='שלח' onMouseOut='onMouseout()'; onMouseOver='onMouse()'; onClick='ajaxFunction()'; /></td> </tr> </table> <div id="ajaxResp"> </div> </body> </html>
וזה הדף עיבוד : search.php
קוד PHP:
<?php session_start(); include ("checker.php"); if (sessioncheck() == false) { setcookie("fail", "no login", time()+200); header("location:entrance.php"); } /* $check = mysql_real_escape_string(htmlspecialchars(stripsla shes(trim($_GET['check'])))); if ($check <> 1){ $_SESSION['wrong'] = 1; header("location:menu.php"); }*/ //\/\/\/\/\\/\/\/\/\/\/\\/\/\/\//**CHECKING DONE**\\/\/\/\/\/\/\/\\/\/\/\/\//\\/\/\/\/\/\\/ $final=""; $id = mysql_real_escape_string(htmlspecialchars(stripsla shes(trim($_GET['id'])))); if (strlen($id) == 0){ echo "nothin in"; }else if (!(is_numeric($id))){ echo "numbers only"; }else{ $final .= '<div dir="rtl" lang="he">'; include("connector.php"); if ((sessioncheck() == true) and ($_SESSION["username"] == "xxxx")){ $flag = 1; $result = mysql_query ("SELECT `handler`,`status`,`xxxx`,`ID`,`name`,`prem`,`path `,`xxxx`,`time`,`xxxx`,`notes` FROM main WHERE ID='$id' AND status='1'") or die (mysql_error()); }else{$result = mysql_query ("SELECT `status`,`ID`,`name`,`prem`,`path`,`xxxx`,`time`,` xxxx`,`notes` FROM main WHERE ID='$id' AND status='1'") or die (mysql_error());} if (!(empty($result))){ $final .= '<div align=center><h2>בקשות שמחכות לטיפול במ"מ</h2></div>'; $final .= "<table cellpadding=1 border=1 width=8% align=center>"; $final .= "<tr><th align=center>תאריך הזנה</th><th align=center nowrap>מ.א.</th><th align=center>שם</th><th align=center>xxxx</th><th nowrap align=center>נתיב ההרשאה</th><th colspan=6 align=center nowrap>xxxx</th></tr>"; while ($row = mysql_fetch_array($result)){ $final .= "<tr><td nowrap align=left>"; $final .= $row["time"]; $final .= "</td>"; $final .= "<td nowrap align=left>"; $final .= $row["ID"]; $final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["name"];$final .= "</td>"; $final .= "<td align=center nowrap>";$final .= $row["prem"]; $final .= "</td>"; $final .= "<td align=left nowrap><div dir=ltr>";$final .= $row["path"];$final .= "</div></td>"; $final .= "<td colspan=6 WRAP=VIRTUAL>";$final .= $row["notes"];$final .= "</td></tr>"; } $final .= '</table>'; $final .= '<br><br>'; } mysql_free_result($result); if ((sessioncheck() == true) and ($_SESSION["username"] == "xxxx")){ $result = mysql_query ("SELECT `handler`,`status`,`sivug`,`ID`,`name`,`prem`,`pat h`,`xxxx`,`time`,`xxxx`,`notes` FROM main WHERE ID='$id' AND status='2'") or die (mysql_error()); }else{$result = mysql_query ("SELECT `status`,`ID`,`name`,`prem`,`path`,`xxxx`,`time`,` xxxx`,`notes` FROM main WHERE ID='$id' AND status='2'") or die (mysql_error());} if (empty($result)){echo "bingo";} if (!(empty($result))){ $final .= '<div align=center><h2>בקשות xxxx</h2></div>'; $final .= "<table cellpadding=1 border=1 width=8% align=center>"; $final .= "<tr><th align=center>תאריך ושעת הזנה</th><th align=center nowrap>xxxx</th><th align=center>שם</th><th align=center>xxxx</th><th nowrap align=center>xxxx</th><th colspan=6 align=center nowrap>xxxx</th>"; if ($flag == 1){$final .= "<th>טופל ע''י</th><th>xxxx</th>";}; $final .= "<th nowrap align=center>זמן הטיפול בבקשה</th></tr>"; while ($row = mysql_fetch_array($result)){ $final .= "</tr><tr><td align=right nowrap><div dir=ltr>";$final .= $row["time"];$final .= "</div></td>"; $final .= "<td nowrap align=left>";$final .= $row["ID"];$final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["name"];$final .= "</td>"; $final .= "<td align=center nowrap>";$final .= $row["prem"];$final .= "</td>"; $final .= "<td align=left nowrap><div dir=ltr>";$final .= $row["path"];$final .= "</div></td>"; $final .= "<td colspan=6 WRAP=VIRTUAL>";$final .= $row["xxxx"];$final .= "</td>"; if ($flag == 1){ $final .= "<td align=center>"; $final .= $row["handler"]; $final .= "</td>"; $final .= "<td align=center>";$final .= $row["xxxx"]; $final .= "</td>"; } $final .= "<td align=right nowrap><div dir=ltr>";$final .= substr($row["bamtime"],0,10);$final .= "</div></td></tr>"; } $final .= '</table>'; $final .= '<br><br>'; mysql_free_result($result); $row; } if ((sessioncheck() == true) and ($_SESSION["username"] == "bamam")){ $result = mysql_query ("SELECT `handler`,`status`,`sivug`,`ID`,`name`,`prem`,`pat h`,`xxxx`,`time`,`xxxx`,`notes` FROM main WHERE ID='$id' AND status='3'") or die (mysql_error()); }else{$result = mysql_query ("SELECT `status`,`ID`,`name`,`prem`,`path`,`xxxx`,`time`,` xxxx`,`notes` FROM main WHERE ID='$id' AND status='3'") or die (mysql_error());} if (!(empty($result))){ $final .= '<div align=center><h2>בקשות שטופלו ונסגרו</h2></div>'; $final .= '<div dir=ltr>'; $final .= "<table cellpadding=1 border=1 width=8% align=center>"; $final .= "<tr><th>מצב סופי</th><th>xxxx</th><th>הערות משו''ב</th><th>שעת ותאריך הטיפול בבקשה</th><th>שעת ותאריך הגשת הבקשה</th>"; if ($flag ==1){$final .= "<th>xxxx</th><th>סיווג</th>";} $final .= "<th>נתיב ההרשאה</th><th>סוג ההרשאה</th><th nowrap>xxxx</th><th nowrap>שם</th></tr>"; $final .= '</div>'; while ($row = mysql_fetch_array($result)){ if ($row["final"] == 1){ $stat = "אושר"; }else if ($row["final"] == 0){ $stat = "לא אושר"; }; $final .= "<tr><td align=right nowrap><div dir=ltr>";$final .= $stat;$final .= "</div></td>"; $final .= "<td align=right nowrap><div dir=ltr>";$final .= $row["xxxxnotes"];$final .= "</div></td>"; $final .= "<td align=right nowrap><div dir=ltr>";$final .= $row["notes"];$final .= "</div></td>"; $final .= "<td nowrap align=left>";$final .= $bamtime;$final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["time"];$final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["handler"];$final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["xxxx"];$final .= "</td>"; $final .= "<td align=cenetr nowrap>";$final .= $row["path"];$final .= "</td>"; $final .= "<td align=center nowrap>";$final .= $row["prem"]; $final .= "</td>"; $final .= "<td align=left nowrap><div dir=ltr>";$final .= $row["ID"];$final .= "</div></td>"; $final .= "<td>";$final .= $row["name"];$final .= "</td></tr>"; } mysql_free_result($result); } $final .= '</div>'; echo $final; } ?>
שוב , הבעיה היא באג'אקס, אם אני נכנס ישירות לדף עיבוד אז זה מחזיר לי תוצאות
מישהו יכול להגיד לי למה זה מחזיר ג'יבריש וקוד גולמי ? ?
|
|