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

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

bilopay 22-12-08 22:09

בעיה | שליחת טופס אם כפתור תמונה
 
הטופס של ההתחברות של האתר שלי לא נישלח אם אני מישתמש בכפתור תמונה אבל אם אני משתמש בכפתור שליחה רגיל הדף נשלח
הקוד של הכפתור של התמונה:

HTML קוד:

<input type="image" name="submit" src="images/conect.gif">

dor77 22-12-08 23:23

http://www.echoecho.com/htmlforms14.htm

אולי זה יעזור לך..

bilopay 23-12-08 10:03

לא עוזר כלום תיראו תקוד של הhtml ותקוד של הphp

PHP קוד:

<?
 
if (!isset($_POST['mylogin']))
{}
else
{
$username htmlspecialchars$_POST['username'] ) ;
$password htmlspecialchars$_POST['password'] ) ;
if (!empty(
$_POST['username']))
{}
else
{
$usernameeror '*חובה להכניס שם משתמש<br />';}
if (!empty(
$_POST['password']))
{}
else
{
$passworderor '*חובה להכניס סיסמה<br />';}
if (!empty(
$_POST['username']) && !empty($_POST['password']))
{}
else
{echo 
'<u>השגיעות הבאות התרכשו</u><br />' $usernameeror '' $passworderor '';}
}
?>


HTML קוד:

<tr>
<td>
<table cellspacing="0" align="right">
<tr>
<td align="center" width="260" height="21" align="left" bgcolor="#FFFFFF" style="background-image: url(images/bar.gif); background-repeat: no-repeat;">
<font color="#FFFFFF" face="arial" style="font-size:13pt;">התחברות</font>
</td>
</tr>
<tr>
<td width="250" height="113" bgcolor="#D3D3D3">
<table>
<tr>
<td>
<form name="myform" action="index.php" method="POST">
<font color="#000000" face="arial" style="font-size:12pt;">
שם משתמש:
</font>
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
<font color="#000000" face="arial" style="font-size:12pt;">
סיסמה:
</font>
</td>
<td>
<input type="text" name="password">
</td>
</tr>
</table>
<center><input type="image" name="mylogin" src="images/conect.gif"></center>
</form>
</td>
</tr>


Erez | TrustMedia.co.il 23-12-08 12:48

יש לך כמה בעיות בקוד PHP
למה לבדוק אם משהו לא קיים ואז לא לעשות כלום ולאחר מכן לעשות else?
תנסה להוריד את ה! ואת כל הelse המיותרים בקוד ותבדוק אם פועל

bilopay 23-12-08 12:53

הקוד עוד לא גמור לפני כול אלה עשיתי גם ניסוי ובימקום כול מה שיש בelse שמתי echo '123'; כדי ליבדוק עם זה מדפיס משהו אם לוחצים על הכפתור וזה לא מדפיס כלום

DvirCohen 23-12-08 15:21

דבר ראשון הלוגיקה של הקוד שלך מטומטמת.
כמו שEAStyle אמר, בשביל מה אתה עושה תנאי ריק? בשביל מה if else?..אפשר להוריד פה חצי מהקוד.

דבר שני, יכול להיות שכפתור תמונה מתנהג כbutton.
מה שאתתה יכול לעשות זה בJS
קוד:

<script type="text/javascript">
function submitForm()
{
  document.form.submit();
}
</script>

<form name="form" method="post" action="...">
<input type="image" ... onclick="submitForm" />
</form>


bilopay 23-12-08 15:33

עשיתי:
HTML קוד:

<tr>
<td width="250" height="113" bgcolor="#D3D3D3">
<table>
<tr>
<td>
<script type="text/javascript">
function submitForm()
{
  document.form.submit();
}
</script>
<form name="myform" action="index.php" method="POST">
<font color="#000000" face="arial" style="font-size:12pt;">
שם משתמש:
</font>
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
<font color="#000000" face="arial" style="font-size:12pt;">
סיסמה:
</font>
</td>
<td>
<input type="text" name="password">
</td>
</tr>
</table>
<center><input type="image" name="mylogin" src="images/conect.gif" onclick="submitForm></center>
</form>
</td>
</tr>

וב php:
PHP קוד:

<?
if (!isset($_POST['mylogin']))
{}
else
{
$username htmlspecialchars$_POST['username'] ) ;
$password htmlspecialchars$_POST['password'] ) ;
if (!empty(
$_POST['username']))
{}
else
{
$usernameeror '*חובה להכניס שם משתמש<br />';}
if (!empty(
$_POST['password']))
{}
else
{
$passworderor '*חובה להכניס סיסמה<br />';}
if (!empty(
$_POST['username']) && !empty($_POST['password']))
{}
else
{echo 
'<u>השגיעות הבאות התרכשו</u><br />' $usernameeror '' $passworderor '';}
}
?>

וזה עדיין לא עובד

Adir 23-12-08 15:59

כשאתה מנסה את הקוד עם Button רגיל זה עובד ?
דרך אגב בקוד HTML האחרון ששלחתי שחכת לשים גרשיים:
HTML קוד:

onclick="submitForm>

DvirCohen 23-12-08 16:27

בפונקציה שנתתי לך אתה צריך לשנות את הform לשם הטופס שלך, במקרה הזה myForm, ושכחת לסגור את הonclick ולקרוא לפונקציה עם ().

Adir 23-12-08 17:32

הנה הקוד המתוקן, תנסה....
HTML קוד:

<tr>
<td width="250" height="113" bgcolor="#D3D3D3">
<table>
<tr>
<td>
<script type="text/javascript">
function submitForm()
{
document.myform.submit();
}
</script>
<form name="myform" action="index.php" method="POST">
<font color="#000000" face="arial" style="font-size:12pt;">
שם משתמש:
</font>
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
<font color="#000000" face="arial" style="font-size:12pt;">
סיסמה:
</font>
</td>
<td>
<input type="text" name="password">
</td>
</tr>
</table>
<center><input type="image" name="mylogin" src="images/conect.gif" onclick="javascript:submitForm();"></center>
</form>
</td>
</tr>



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

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