הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 01-03-10, 21:18   # 1
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

בעייה בהצבת עוגיות..הדרים נשלחו..

שלום.
בניתי טופס התחברות.
הרעיון הוא כזה:

אם הכפתור נלחץ - המערכת תבדוק אם הפרטים נכונים, אם כן תחבר את המשתמש, אם לא (else) מציג לו את הטופס עם שגיאה.
אם הכפתור לא נשלח - מציג לו את הטופס בלבד.

כשאני מצליח להתחבר..אני מקבל שגיאה:
Cannot modify header information - headers already sent by
אני מקבל פעמיים, השורות שמצויינות הן השורות של הצבת העוגיות.


זה הקוד המלא:

PHP קוד:


<?php

mysql_connect
("localhost""root""");
mysql_select_db("phpmyadmin"); 

$user_name mysql_real_escape_string(htmlspecialchars($_POST['user_name']));
$password mysql_real_escape_string(htmlspecialchars(md5($_POST['password'])));

$query mysql_query("SELECT * FROM users WHERE user_name='$user_name'"); 
$row=mysql_fetch_array($query);

$row_password=$row['password'];
$row_user_name=$row['user_name'];
$password_cookie=$row['password'];
$user_name_cookie=$row['user_name'];

if (isset(
$_POST['submit']))
{
if (
$row_password==$password && $row_user_name==$user_name)
{
    
setcookie("username"$user_nametime()+60000);
    
setcookie("id"$id_cookietime()+60000);
    echo 
'<meta http-equiv="refresh" content="0;url=index.php" />'
}
  else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
          <div id="register_message"><p class="failed">Login Fail!</p>
        <span class="failed">Please check your deatiles and try again.</span></div> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
}
        '
;
}

}
else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
        '
;
}


?>
לא כתבתי שום דבר לפני כן, הדף ריק לגמרי..מה נחשב "header"? אולי הלולאה שם?

תודה רבה לכם
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote
ישן 01-03-10, 21:42   # 2
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

יש לך 2 אנטרים בראש הדף.
  Reply With Quote
ישן 01-03-10, 21:51   # 3
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

מחקתי אותם..עדיין.
אנטר יכול לעשות דבר כזה? חח
בכל אופן לא עזר..אתה רואה משהו אחר אולי?

טנקס (:
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote
ישן 01-03-10, 22:27   # 4
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

כל טקסט. שלח מחדש את מה שעכשיו כתוב.

באיזה קידוד אתה שומר את זה?
  Reply With Quote
ישן 01-03-10, 22:43   # 5
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

כתוב בדיוק אותה שגיאה.
הקידוד הוא utf-8.
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote
ישן 01-03-10, 22:46   # 6
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

1. את הקוד. שלח את הקוד בדיוק כמו שמופיע לך בקובץ.
2. שמור כ-UTF WITHOUT BOM.
  Reply With Quote
ישן 01-03-10, 22:58   # 7
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

זה הקוד:
PHP קוד:
<?php
mysql_connect
("localhost""root""");
mysql_select_db("phpmyadmin"); 
$user_name mysql_real_escape_string(htmlspecialchars($_POST['user_name']));
$password mysql_real_escape_string(htmlspecialchars(md5($_POST['password'])));
$query mysql_query("SELECT * FROM users WHERE user_name='$user_name'"); 
$row=mysql_fetch_array($query);
$row_password=$row['password'];
$row_user_name=$row['user_name'];
$password_cookie=$row['password'];
$user_name_cookie=$row['user_name'];
if (isset(
$_POST['submit']))
{
if (
$row_password==$password && $row_user_name==$user_name)
{
    
setcookie("username"$user_nametime()+60000);
    
setcookie("id"$id_cookietime()+60000);
    echo 
'<meta http-equiv="refresh" content="10;url=index.php" />'
}
  else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
          <div id="register_message"><p class="failed">Login Fail!</p>
        <span class="failed">Please check your deatiles and try again.</span></div> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
}
        '
;
}

}
else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
        '
;
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Your Private Homepage</title>
    <meta  http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
body {
    background-image:url('background.png');
    background-repeat: repeat-x;
}

#top_menu {
    text-align: right;
    position:relative;
    right:30px;
    top:0px;
}
.menu_class a:link {
    color:gray; 
    font-size:10pt;  
    font-family:Arial; 
     text-decoration: underline;
}
.menu_class a:visited {
         color:gray; 
         font-size:10pt; 
         font-weight:normal;  
         font-family:Arial; 
         text-decoration: underline;
}
a.links {
        display: block;
        padding-top: 24px;
        height: 46px;
        width: 200px;
        color: #484848;
        font-family: Arial, sans-serif;
        font-size:18px;
        font-weight: bold;
        text-decoration: none;
}
a.links:hover {
        display: block;
        padding-top: 24px;
        height: 46px;
        width: 200px;
        color: gray;
        font-family: Arial, sans-serif;
        font-size:18px;
        font-weight: bold;
        text-decoration: none;
}
h1 {
        color:#3366CC; 
        font-size:25pt; 
        font-weight:bold;  
        font-family:Arial; 
        text-align: left;
        margin-top: 60px;
        margin-right: 0px;
        margin-bottom: 0px;
        margin-left: 100px;
        border: 0px solid #000000;
}
#form {
     position:relative;
     left:87px;
     top:40px;
        width:500px;
}
span.field {
        text-align:left;
        direction:ltr;
        color:#505050; 
        font-size:12pt;
        font-weight:bold;  
        font-family:Arial;
}
p.failed {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:15pt;
        font-weight:bold;  
        font-family:Arial;
}
span.succed {
    text-align:left;
 direction:ltr;
 color:green; 
 font-size:12pt;
 font-weight:normal;  
 font-family:Arial;
}
p.succed {
 text-align:left;
 direction:ltr;
 color:green; 
 font-size:15pt;
 font-weight:bold;  
 font-family:Arial;
}
span.errors {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:10pt;
        font-weight:normal;  
        font-family:Arial;
}
span.failed {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:10pt;
        font-weight:bold;  
        font-family:Arial;
}
#register_message {
        position:relative;
        left:100px;
        top:17px;
        width:450px;
        border: 0px solid #000000;
}
table#registertable  { 
        border: 0px solid #000000;
        border-right: 0px solid #000000;
}
#copyrights {
    clear:both;
    padding:80px 0px 15px;
    text-align:center;
    color:gray; 
    font-size:10pt;  
    font-family:Arial; 
}
.button {
        border: 1px solid #505050;
        background: #f5f5f5;
        cursor:pointer;
        width: 100px;
        padding-left:5px;
        padding-right:5px;
        padding-bottom:5px;
        padding-top:5px;
        text-align: center;
        text-align:center;
        color:#505050; 
        font-size:12pt;
        font-weight:bold;  
        font-family:Arial;
}
label {
        display: block;
        width: 180px;
        float: left;
        margin: 2px 4px 6px 4px;
        text-align: left;
}
#submit {
        color: #fff;
        font-size: 0;
        width: 68px;
        height: 28px;
        border: none;
        background: #ffffff url(signin_btn.bmp) 0 0 no-repeat;
        cursor:pointer;
}
}
</style>
</head>
</html>
בול מה שיש בקובץ.

בקשר לקידוד, איך שומרים קידוד כזה?
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote
ישן 01-03-10, 23:46   # 8
yNaxon
אקס מנהל
 
yNaxon's Avatar
 
מיני פרופיל
תאריך הצטרפות: Dec 2005
מיקום: תל אביב
הודעות: 7,481

yNaxon לא מחובר  

נסה במקום
קוד:
echo '<meta http-equiv="refresh" content="10;url=index.php" />';
לכתוב:
קוד:
header("location: index.php");
רק תזכור להוסיף:

קוד:
ob_start();
אחרי השורה הראשונה
<?php
__________________
בברכה,
יונתן.
  Reply With Quote
ישן 02-03-10, 01:50   # 9
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

לא..
עכשיו יש שלשושה הודעות כאלה:

Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\a\sign_in.php:1) in c:\wamp\www\a\sign_in.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\a\sign_in.php:1) in c:\wamp\www\a\sign_in.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\a\sign_in.php:1) in c:\wamp\www\a\sign_in.php on line 19

זה הקוד..למקרה שטעיתי..:


PHP קוד:
<?php
ob_start
();
mysql_connect("localhost""root""");
mysql_select_db("phpmyadmin"); 
$user_name mysql_real_escape_string(htmlspecialchars($_POST['user_name']));
$password mysql_real_escape_string(htmlspecialchars(md5($_POST['password'])));
$query mysql_query("SELECT * FROM users WHERE user_name='$user_name'"); 
$row=mysql_fetch_array($query);
$row_password=$row['password'];
$row_user_name=$row['user_name'];
$password_cookie=$row['password'];
$user_name_cookie=$row['user_name'];
if (isset(
$_POST['submit']))
{
if (
$row_password==$password && $row_user_name==$user_name)
{
    
setcookie("username"$user_nametime()+60000);
    
setcookie("id"$id_cookietime()+60000);
        
header("location: index.php");
}
  else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
          <div id="register_message"><p class="failed">Login Fail!</p>
        <span class="failed">Please check your deatiles and try again.</span></div> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
}
        '
;
}

}
else
{
        echo 
'
    
        <div id="top_menu">
        <span class="menu_class">
        <a href="sign_in.php">Login</a>&nbsp;&nbsp;
        <a href="sign_up.php">Register</a>
        </span>
        </div>
        
        <h1>Login to your account...</h1> 
        
        <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="user_name" id="user_name" dir="ltr" value="" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  value="" style="width:200px;" maxlength="15">
            </td>      
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
        </div>
    
        <div id="copyrights">
        © All rights reserved.
        </div>
        '
;
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Your Private Homepage</title>
    <meta  http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
body {
    background-image:url('background.png');
    background-repeat: repeat-x;
}

#top_menu {
    text-align: right;
    position:relative;
    right:30px;
    top:0px;
}
.menu_class a:link {
    color:gray; 
    font-size:10pt;  
    font-family:Arial; 
     text-decoration: underline;
}
.menu_class a:visited {
         color:gray; 
         font-size:10pt; 
         font-weight:normal;  
         font-family:Arial; 
         text-decoration: underline;
}
a.links {
        display: block;
        padding-top: 24px;
        height: 46px;
        width: 200px;
        color: #484848;
        font-family: Arial, sans-serif;
        font-size:18px;
        font-weight: bold;
        text-decoration: none;
}
a.links:hover {
        display: block;
        padding-top: 24px;
        height: 46px;
        width: 200px;
        color: gray;
        font-family: Arial, sans-serif;
        font-size:18px;
        font-weight: bold;
        text-decoration: none;
}
h1 {
        color:#3366CC; 
        font-size:25pt; 
        font-weight:bold;  
        font-family:Arial; 
        text-align: left;
        margin-top: 60px;
        margin-right: 0px;
        margin-bottom: 0px;
        margin-left: 100px;
        border: 0px solid #000000;
}
#form {
     position:relative;
     left:87px;
     top:40px;
        width:500px;
}
span.field {
        text-align:left;
        direction:ltr;
        color:#505050; 
        font-size:12pt;
        font-weight:bold;  
        font-family:Arial;
}
p.failed {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:15pt;
        font-weight:bold;  
        font-family:Arial;
}
span.succed {
    text-align:left;
 direction:ltr;
 color:green; 
 font-size:12pt;
 font-weight:normal;  
 font-family:Arial;
}
p.succed {
 text-align:left;
 direction:ltr;
 color:green; 
 font-size:15pt;
 font-weight:bold;  
 font-family:Arial;
}
span.errors {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:10pt;
        font-weight:normal;  
        font-family:Arial;
}
span.failed {
        text-align:left;
        direction:ltr;
        color:red; 
        font-size:10pt;
        font-weight:bold;  
        font-family:Arial;
}
#register_message {
        position:relative;
        left:100px;
        top:17px;
        width:450px;
        border: 0px solid #000000;
}
table#registertable  { 
        border: 0px solid #000000;
        border-right: 0px solid #000000;
}
#copyrights {
    clear:both;
    padding:80px 0px 15px;
    text-align:center;
    color:gray; 
    font-size:10pt;  
    font-family:Arial; 
}
.button {
        border: 1px solid #505050;
        background: #f5f5f5;
        cursor:pointer;
        width: 100px;
        padding-left:5px;
        padding-right:5px;
        padding-bottom:5px;
        padding-top:5px;
        text-align: center;
        text-align:center;
        color:#505050; 
        font-size:12pt;
        font-weight:bold;  
        font-family:Arial;
}
label {
        display: block;
        width: 180px;
        float: left;
        margin: 2px 4px 6px 4px;
        text-align: left;
}
#submit {
        color: #fff;
        font-size: 0;
        width: 68px;
        height: 28px;
        border: none;
        background: #ffffff url(signin_btn.bmp) 0 0 no-repeat;
        cursor:pointer;
}
}
</style>
</head>
</html>
תודה (:
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote
ישן 02-03-10, 02:24   # 10
יניב בן צבי
חבר בקהילה
 
מיני פרופיל
תאריך הצטרפות: Nov 2007
הודעות: 162

יניב בן צבי לא מחובר  

יש לך בעיה בקידוד של הקובץ הפעלתי את הקוד ואין שגיאה... תשנה את הקידוד לANSI אפשרי בעזרת הכתבן הרגיל או בעזרת תוכנת עריכה כלשהי אני משתמש בeclipse
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


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

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