הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   בעיה מוזרה ב-PHP (https://hosts.co.il/forums/showthread.php?t=68787)

Jonathan Zeierman 25-10-08 23:24

בעיה מוזרה ב-PHP
 
שלום לכולם,
נתקלתי בבעיה הבאה:
עשיתי טופס לשליחת איימיל ושילבתי אותו בתוך דף מוגן, כשאני נכנס לטופס אני מקבל הודעה כזו:
קוד:

Fatal error: Call to undefined function showform() in /home/ventrilo/domains/ventrilo.co.il/public_html/yoni/bug_report.php on line 59
זה לא הגיוני אני יגיד לכם למה...
ניסתי להיכנס לדף רגיל פשוט לשים תקוד בדף אחר ולראות עם אין תקלה והוא עובד!
הנה הקודים שלי:
זה הדף שמגן:
PHP קוד:

<?php
session_start
();
include(
"config.php");
if (isset(
$_SESSION['user']) == FALSE && isset($_SESSION['pass']) == FALSE)
{
echo (
"$erorr");
}
if (isset(
$_SESSION['user']) == TRUE && isset($_SESSION['pass']) == TRUE)
{
echo (
"$back_button");
include(
"bug_send.php");
}
?>

וזה טופס האיימיל:
PHP קוד:

<?php
////////////////////////////////////////////////////////////////////////////
$myemail "yoni@ventrilo.co.il"// איימלים לקבלת איימיל
////////////////////////////////////////////////////////////////////////////
switch($_GET["act"]) {
case 
"send":
send();
break;
 
default:
showform();
break;
}
function 
showform() {
echo <<<END
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<form action="?act=send" method="post" name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">
<div dir="rtl" align="center">
<center>
<html dir="rtl">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#C0C0C0" width="90%">
<p dir="rtl"><b><i><u><font size="4" face="Arial" color="#FFFFFF">דיווח על תקלה:</font></u></i></b></p>
<br>
<tr>
<td width="40%">
<p dir="rtl"><span dir="rtl"><font face="Arial" size="2" color="#FFFFFF">שם:</font></span></td>
<td width="60%">
<p dir="rtl"><span dir="rtl"><font color="#FFFFFF" face="Arial"><input type="text" name="name" size="22"></font></span></td>
</tr>
<tr>
<td width="40%">
<p dir="rtl"><span dir="rtl"><font face="Arial" size="2" color="#FFFFFF">סוג התקלה:</font></span></td>
<td width="60%">
<p dir="rtl"><span dir="rtl"><font color="#FFFFFF" face="Arial"><input type="text" name="lname" size="22"></font></span></td>
</tr>
<tr>
<td width="40%">
<p dir="rtl"><span dir="rtl"><font face="Arial" size="2" color="#FFFFFF">כתובת דואר אלקטרוני:</font></span></td>
<td width="60%">
<p dir="rtl"><span dir="rtl"><font color="#FFFFFF" face="Arial"><input type="text" name="email" size="22"></font></span></td>
</tr>
<tr>
<td width="40%">
<p dir="rtl"><span dir="rtl"><font face="Arial" size="2" color="#FFFFFF">פירוט התקלה:</font></span></td>
<td width="60%">
<p dir="rtl"><span dir="rtl"><font color="#FFFFFF" face="Arial"><textarea rows="6" name="notes" cols="29"></textarea></font></span></td>
</tr>
<tr>
<td width="100%" colspan="2">
<center>
<p dir="rtl"><span dir="rtl"><font face="Arial"><font color="#FFFFFF">
<input type= submit value="שלח" name="submit"></font><font size="2" color="#FFFFFF"> </font>
<font color="#FFFFFF">
<input type= reset value="נקה" name="reset"></font><font size="2" color="#FFFFFF"> </font>
</font></span></p>
</center></td>
</tr>
</table>
</center>
</div>
</form>
END;
echo 
"<center>";
echo 
'<p dir="rtl">כתובת האייפי שלך נשמרת מטעמי אבטחה:</p>';
echo 
$_SERVER['REMOTE_ADDR'];
echo 
"</center>";
echo 
'<br>';
echo 
'<br>';
echo (
"$credit");
}
function 
send() {
global 
$myemail;
$name $_POST["name"];
$lname $_POST["lname"];
$email $_POST["email"];
$notes $_POST["notes"];
$date date("d/m/Y");
$ip $_SERVER['REMOTE_ADDR'];
$to $myemail;
$subject "דיווח על תקלה מהפאנל";
$body "\nשם: $name\nשם משפחה: $lname\nאיימיל: $email\nהתקלה: $notes\nתאריך דיווח: $date\nאייפי: $ip";
$from $email;
mail($to,$subject,$body,$from);
echo <<<HTML
<center>
<p dir="rtl">טופס הדיווח נשלח בהצלחה !</p>
<meta http-equiv="Refresh" content="3; URL=contact.php">
</center>
HTML;
}
?>

תודה לעוזרים, יוני.

O-B 26-10-08 00:56

אתה אמוור להגדיר את הפונקציות לפני שאתה משתמש בהם..

omercnet 26-10-08 01:05

יש לי הרגשה שכל הbreakים האלה אולי עושים בלאגן עם ההגדרה של הפונקציה, וגם אם לא, בכל מקרה יש מתודולוגיה לכתיבת קוד,
קודם כל מכריזים על כל הפונקציות (עדיף אפילו בעמוד אחר, ולעשות לו include) ורק אז קוראים להם

תעלה את ההכרזה של הפונקציה למעלה, ואז תקרא לה אח"כ, תראה עם זה עוזר

וחוץ מזה איך אתה יכול לכתוב בלי indentation ? לא משגע אותך לקרוא את הקוד ככה?


ציטוט:

נכתב במקור על ידי O-B (פרסם 676962)
אתה אמוור להגדיר את הפונקציות לפני שאתה משתמש בהם..

זה לא חובה בPHP, כי זה preprocessor

Jonathan Zeierman 28-10-08 06:10

מה שמוזר שעל השרת יש PHP5, בדקתי על שרת עם PHP4 והקוד עובד אותו קוד אין שגיאה של showfrom...


כל הזמנים הם GMT +2. הזמן כעת הוא 04:43.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ