לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #7  
ישן 30-03-2009, 21:36
  myadmin myadmin אינו מחובר  
 
חבר מתאריך: 15.02.09
הודעות: 292
בתגובה להודעה מספר 1 שנכתבה על ידי myadmin שמתחילה ב "form faq"

USER_LOGIN.PHP
<?php require_once("sqlconnction.php") ; ?>
<?php include "function.php" ;?>
<?php
if(isset($_POST['submit'])) {

$errors = array() ;
$required_field =array('user_login' ,'pass_login') ;
foreach($required_field as $fieldname) {
if (!isset($_POST[$fieldname] ) ||
empty($_POST[$fieldname] ) && /// and not 0
($_POST[$fieldname] !== 0 )) {
$errors[] = $fieldname ;
}
}
// length check for entry
$field_with_lengths =array( 'user_login' => 30) ;
foreach($field_with_lengths as $fieldname =>$maxlength) {
if(strlen(trim(mysql_prep(@$_POST[$fieldname]))) > $maxlength) {
$errors[] = $fieldname ;
}
}

if (empty($errors)) {

$user_name = mysql_prep(@$_POST['user_login' ]) ;
$password = mysql_prep(@$_POST['pass_login']) ;
$hased_password = sha1($password) ;


// perforum update
$query = "SELECT id ,user_name " ;
$query .= "FROM users " ;
$query .= "WHERE user_name = '{$user_name } ' " ;
$query .= " AND password = '{$hased_password } ' ";
;
// insert in my sql
$result =mysql_query($query ,$connection) ;
if (!$result) {
echo mysql_error() ; }


//check if there is line change
//this is mysql_num_rows if we will resicve anouer line
if(mysql_num_rows($result) == 1) {// single page error messaging
// Success
// only on username match
//password autocitai
// $founduser = mysql_fetch_array($result ) ;

// redirect_to("staff.php") ;
}else{

$message = "Bad username password comination" ;
}
}else{

$message = "please enter username/password" ; }

}
include 'log_in_front_page.php';
mysql_close($connection) ;
?>

LOG_IN.php
<?php include "header.php" ; ?>
<?php require("user_login.php") ; ?>

<table id="structure">
<tr>
<td id="navigation">

&nbsp;
</td >
<td id="page">
<h2>User login</h2>
<p>Please enter username and password ,</p>
&nbsp;




<?php
if(isset($message )) {

echo $message ; }
?>
<?php
if(!empty($errors)) {
echo $errors ; }
?>

<form action="user_login.php" method="post" >
<p>User name : <input type ="text" name = "user_login" size = "30" maxlength ="30" id="username" /> </p>
<form action="user_login.php" method="post" >
<p>Password : <input type ="password" name = "pass_login" size = "30" maxlength ="30" id="password" /> </p>
&nbsp;
&nbsp;

<input type="submit" name="submit" value="Log in" />
<input type="reset" value="Reset" />

</form>





</td>
</tr>
</table>
</div>
<?php include "footer.php" ; ?>
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #9  
ישן 30-03-2009, 22:17
  myadmin myadmin אינו מחובר  
 
חבר מתאריך: 15.02.09
הודעות: 292
בתגובה להודעה מספר 1 שנכתבה על ידי myadmin שמתחילה ב "form faq"

USER_login.php
<?php require_once("sqlconnction.php") ; ?>
<?php include "function.php" ;?>
<?php
if(isset($_POST['submit'])) {

$errors = array() ;
$required_field =array('user_login' ,'pass_login') ;
foreach($required_field as $fieldname) {
if (!isset($_POST[$fieldname] ) ||
empty($_POST[$fieldname] ) && /// and not 0
($_POST[$fieldname] !== 0 )) {
$errors[] = $fieldname ;
}
}
// length check for entry
$field_with_lengths =array( 'user_login' => 30) ;
foreach($field_with_lengths as $fieldname =>$maxlength) {
if(strlen(trim(mysql_prep(@$_POST[$fieldname]))) > $maxlength) {
$errors[] = $fieldname ;
}
}

if (empty($errors)) {

$user_name = mysql_prep(@$_POST['user_login' ]) ;
$password = mysql_prep(@$_POST['pass_login']) ;
$hased_password = sha1($password) ;


// perforum update
$query = "SELECT id ,user_name " ;
$query .= "FROM users " ;
$query .= "WHERE user_name = '{$user_name } ' " ;
$query .= " AND password = '{$hased_password } ' ";
;
// insert in my sql
$result =mysql_query($query ,$connection) ;
if (!$result) {
echo mysql_error() ; }


//check if there is line change
//this is mysql_num_rows if we will resicve anouer line
if(mysql_num_rows($result) == 1) {// single page error messaging
// Success
// only on username match
//password autocitai
// $founduser = mysql_fetch_array($result ) ;

// redirect_to("staff.php") ;
}else{
redirect_to("log_in_front_page.php") ;
$message = "Bad username password comination" ;
}
}else{

$message = "please enter username/password" ; }

}
include 'log_in_front_page.php';
mysql_close($connection) ;
?>

log_in_front_page.php


<?php include "header.php" ; ?>
<?php require("user_login.php") ; ?>

<table id="structure">
<tr>
<td id="navigation">

&nbsp;
</td >
<td id="page">
<h2>User login</h2>
<p>Please enter username and password ,</p>
&nbsp;




<?php
if(isset($message )) {

echo $message ; }
?>
<?php
if(!empty($errors)) {
echo $errors ; }
?>

<form action="user_login.php" method="post" >
<p>User name : <input type ="text" name = "user_login" size = "30" maxlength ="30" id="username" /> </p>
<form action="user_login.php" method="post" >
<p>Password : <input type ="password" name = "pass_login" size = "30" maxlength ="30" id="password" /> </p>
&nbsp;
&nbsp;

<input type="submit" name="submit" value="Log in" />
<input type="reset" value="Reset" />

</form>





</td>
</tr>
</table>
</div>
<?php include "footer.php" ; ?>


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #11  
ישן 30-03-2009, 22:25
  myadmin myadmin אינו מחובר  
 
חבר מתאריך: 15.02.09
הודעות: 292
בתגובה להודעה מספר 1 שנכתבה על ידי myadmin שמתחילה ב "form faq"

קוד PHP:
 USER_login.php 
<?php require_once("sqlconnction.php") ; ?>  
<?php  include "function.php" ;?> 
<?php 
if(isset($_POST['submit'])) {

$errors = array() ;
$required_field =array('user_login' ,'pass_login') ;
    foreach(
$required_field as $fieldname) {
     if (!isset(
$_POST[$fieldname] ) || 
     empty(
$_POST[$fieldname] )  &&    /// and not 0 
     
($_POST[$fieldname] !== )) {
     
$errors[] = $fieldname 
  }
     }
// length check for entry 
     
$field_with_lengths =array( 'user_login' => 30)    ;
      foreach(
$field_with_lengths as $fieldname =>$maxlength) {
       if(
strlen(trim(mysql_prep(@$_POST[$fieldname]))) > $maxlength) {
       
$errors[] = $fieldname ;                          
}
    }

if (empty(
$errors)) {

                    
$user_name mysql_prep(@$_POST['user_login' ]) ;
                      
$password mysql_prep(@$_POST['pass_login']) ;
                       
$hased_password sha1($password) ;
                      

// perforum update 
                
$query "SELECT id ,user_name  " ;
                 
$query .=  "FROM users   " ;  
                  
$query .= "WHERE user_name = '{$user_name } ' " 
                    
$query .= " AND  password = '{$hased_password } ' "
             ;
// insert in my sql 
              
$result =mysql_query($query  ,$connection) ;                
               if (!
$result) {             
               echo  
mysql_error()  ; }


                
//check if there is line change 
            //this is mysql_num_rows if we will resicve anouer line
                
if(mysql_num_rows($result) == 1) {// single page error messaging
                 // Success 
                   // only on username match 
                //password autocitai
           //     $founduser  = mysql_fetch_array($result ) ; 
                 
                //      redirect_to("staff.php") ; 
               
}else{
                     
redirect_to("log_in_front_page.php") ;
                   
$message =   "Bad username password comination"   
                       }                                                                         
   }else{
                       
                     
$message =  "please enter username/password" ; }
                         
}
include 
'log_in_front_page.php';
mysql_close($connection) ;
?>

log_in_front_page.php


<?php include "header.php" ?> 
<?php require("user_login.php") ; ?>
     
  <table  id="structure">
                       <tr> 
                                  <td id="navigation">
 
                                          &nbsp;
                                            </td >
                                         <td id="page">
                                              <h2>User login</h2>
                                                   <p>Please  enter username and password ,</p>
                                                        &nbsp;

       
                                         

<?php 
                      
if(isset($message )) {
                           
                           echo 
$message  ; } 
?>
<?php 
                
if(!empty($errors)) {
                       echo 
$errors ; }
?>
 
                      <form action="user_login.php" method="post" >
<p>User name : <input type ="text" name = "user_login" size = "30" maxlength ="30" id="username" /> </p>
                             <form action="user_login.php" method="post" >
<p>Password : <input type ="password" name = "pass_login" size = "30" maxlength ="30" id="password" /> </p>
&nbsp;
&nbsp;

<input type="submit" name="submit" value="Log in" />
<input type="reset" value="Reset" />

</form>

   
                             


                                                           </td>
                                                          </tr>
                                                         </table>
                                                         </div>
               <?php include "footer.php" ?> 

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #12  
ישן 30-03-2009, 22:35
  משתמש זכר dorM dorM אינו מחובר  
מנהל
 
חבר מתאריך: 26.07.08
הודעות: 6,473
בתגובה להודעה מספר 11 שנכתבה על ידי myadmin שמתחילה ב "[left] [PHP] USER_login.php..."

אוה כבר יש שבבים של תקווה

שמתי לב שהשתמשת ברווחים בשביל ההזחות.
במקום זה, תוכל להשתמש בלחצן TAB שבמקלדת (קצת מתחת לכפתור Esc, ובדיוק מעל הכפתור Caps Lock).
אם תשתמש בעורך טקסט טוב, כמו ++Notepad, תוכל לכתוב קוד בקלות יותר.

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

כנראה לא שמת לב כי עשיתי זאת אחרי עריכה, אבל תלמד לשרשר נכון:
http://www.fresh.co.il/vBulletin/sh...ad.php?t=157895

לפני הקוד הבא:
קוד PHP:
 if(isset($message )) {
                           
                           echo 
$message  ; } 


תכתוב:
קוד PHP:
 var_dump($message); 


יכול להיות של הערך של המשתנה נדרס או משהו דומה, לכן אני אומר לך לבצע זאת.

דבר נוסף שמוזר לי מאוד הוא האינקלודים הבאים:

קוד PHP:
<?php include "header.php" ?> 
<?php require("user_login.php") ; ?>


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

אני ממליץ שתלמד PHP מההתחלה, בדוקומנטציה של האתר http://www.php.net

בהצלחה
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 02:37

הדף נוצר ב 0.14 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר