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

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



  #1  
ישן 08-11-2008, 12:13
צלמית המשתמש של -=M_P=-
  משתמש זכר -=M_P=- -=M_P=- אינו מחובר  
 
חבר מתאריך: 13.04.08
הודעות: 5
שאלה עזרה בבנית מערכת הרשה

עזרה בבנית מערכת משתמשים אני צריך רק עזרה איפו לשים יש לי את כל הדברים מסד נתונים רק איפו לשים והינה הטקסט אויפו לשים כל אחד אנא עזרו לי אני יודה מאוד
קוד PHP:
<?
// Constants page, cons.php
define(&quot;DB_SERVER&quot;, &quot;localhost&quot;); // Server
define(&quot;DB_USER&quot;, &quot;username&quot;); // Username
define(&quot;DB_PASS&quot;, &quot;userpass&quot;); // User pass
define(&quot;DB_NAME&quot;, &quot;database&quot;); // Database
mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); // Connection
mysql_select_db(DB_NAME) or die(mysql_error()); // Selection of database
?>



<?
// Register Process, register.php

// Includes the Constants
include(&quot;cons.php&quot;);

// sets all the variables needed to register
$pass = $_GET['pass']; // set $pass as the first pass
$pass2 = $_GET['pass2']; // sets $pass2 as the re-entered pass
$name = $_GET['name']; // sets $name as the name chosen

// Processing the data
if ($name) { // if $name is set
$re = mysql_num_rows(mysql_query(&quot;SELECT * FROM user WHERE user='$name'&quot;));
  if ($re >= 1) { // If the username exists
    $error = &quot;* Username already in use&quot;; // Set $error
    $err = 1; // set $err as 1
  }
  else { // user doesn't exist
    if ($pass == $pass2) { // If the passwords match
      $pass = md5($pass); // Encodes the pass
      mysql_query(&quot;INSERT INTO user (user, pass) VALUES ('$name','$pass')&quot;); // Creates the user
      $reg = &quot;Registration successful!&quot;; // Sets $reg as a sucess message
      header(&quot;Location: log.php?reg=$reg&quot;); // Re-locates to the login screen
    }
    else { // The passwords don't match
      $error = &quot;* Passwords different!&quot;; // Sets $error
      $err = 2; // Sets $err as 2
    }
  }
}
else { // If $name isn't set
  $error = &quot;* Enter a username&quot;; // sets $error
  $err = 1; // sets $err as 1
}
if ($err >= 1) { // if $err is greater than or equal to 1
header(&quot;Location: reg.php?error=$error&err=$err&quot;); // re-locates to the registration page with the error!
}
?>



<?
// Register script, reg.php

// Includes the Constants
include(&quot;cons.php&quot;);

// The registration form
$error = $_GET['error'];
$err = $_GET['err'];
?>
<form action=&quot;register.php&quot;>
<input type=&quot;text&quot; name=&quot;name&quot;> Username <font size=&quot;-2&quot; color=&quot;#FF0000&quot;>
<? 
if ($err == 1) { 
echo $error;

?></font><br>
<input type=&quot;password&quot; name=&quot;pass&quot;> Password <font size=&quot;-2&quot; color=&quot;#FF0000&quot;>
<? 
if ($err == 2) { 
echo $error;

?></font><br>
<input type=&quot;password&quot; name=&quot;pass2&quot;> Re-type Password<br>
<input type=&quot;submit&quot; value=&quot;Register!&quot;>
</form>



<? 
// This is the main part, log.php

// Constants
include(&quot;cons.php&quot;);
$ip = $_SERVER['REMOTE_ADDR']; // Gets the users IP address
$brow = $_SERVER['HTTP_USER_AGENT']; // Gets the users Browser
$reg = $_GET['reg']; // Sets the $reg variable

// Makes sure the user is logged in
$r = mysql_query(&quot;SELECT * FROM active_users WHERE ip='$ip' AND browser='$brow'&quot;);
$re = mysql_fetch_array($r);
$user = $re['name']; // Sets $user as the users name

// If the user exists
if ($user) {
  echo &quot;Welcome, &quot;.$user.&quot;<br>&quot;; // Welcome message
  echo &quot;<a href=&quot;login.php?out=yes&user=$user&quot;>Logout</a>&quot;; // Logout button
  echo &quot;<br><br><br>&quot;;
  
  /**************************************************  **/
  /***** This shows how many users are active and *****/
  /*********** it shows their names too! **************/
  /**************************************************  **/
  
  $ro = mysql_query(&quot;SELECT * FROM active_users&quot;);
  $active = mysql_num_rows($ro); // sets $active as the number of active users
  echo &quot;Currently active users: &quot;.$active.&quot;<br>&quot;; // lists the number of active users
  
  // Actually lists the users
  while ($ra = mysql_fetch_array($ro)) {
    $name = $ra['name']; // Sets $name as the users' names
    
    // Lists the users names
    if ($i != ($active - 1)) { // if $i doesn't equal $active minus 1
      echo $name.&quot; | &quot;;
    }
    else {
      echo $name;
    }
    
  $i++; // increase temp variable
  }
  /******************************************/
  /********** End of active users! **********/
  /******************************************/
}
else {
if ($reg) {
echo $reg;
}
/********** Show the login form ************/
?>
<form action=&quot;login.php&quot;>
<input type=&quot;text&quot; name=&quot;name&quot;> Username<br>
<input type=&quot;password&quot; name=&quot;pass&quot;> Password<br>
<input type=&quot;submit&quot; value=&quot;Login!&quot;>
</form>
<?
/*********** End of login form ************/
}
?>



<?
// This is the login part, login.php

// includes the constants
include(&quot;cons.php&quot;);
$name = $_GET['name']; // sets the username
$pass = $_GET['pass']; // sets the password
$r = mysql_query(&quot;SELECT * FROM user WHERE user='$name'&quot;);

// logout section
$logout = $_GET['out']; // makes sure their logging out
$user = $_GET['user']; // gets the username
if ($logout == &quot;yes&quot;) {
mysql_query(&quot;DELETE FROM active_users WHERE name='$user'&quot;); // Logs them out
}

// Main Login part
while ($ro = mysql_fetch_array($r)) {
$pass2 = $ro['pass']; // sets $pass2 as the actual password
  if (md5($pass) == $pass2) { // makes sure password entered is the same as $pass2
    $user = $_SESSION['username'] = $name; // starts the session
    $ip = $_SERVER['REMOTE_ADDR']; // Users ip address
    $brow = $_SERVER['HTTP_USER_AGENT'];
    $time = time(); // gets the time
    // Makes the user an active user!
    mysql_query(&quot;DELETE FROM active_users WHERE name='$user'&quot;);
    mysql_query(&quot;INSERT INTO active_users (name,timestamp,ip,browser) VALUES ('$user','$time','$ip','$brow')&quot;);
  }
}

// Returns the user after logging in.
header(&quot;Location: log.php&quot;);
?>



/************************************************** */
/*************** The two mysql tables *****************/
/************************************************** */

קוד PHP:
 DROP TABLE IF EXISTS user;
CREATE TABLE IF NOT EXISTS `user` (
  
id int(11NOT NULL auto_increment,
  `
uservarchar(32NOT NULL default '',
  
pass varchar(32NOT NULL default '',
  
PRIMARY KEY  (id)
ENGINE=HEAP;


DROP TABLE IF EXISTS active_users;
CREATE TABLE IF NOT EXISTS active_users (
  
id int(11NOT NULL auto_increment,
  
name varchar(32NOT NULL default '',
  `
timestampvarchar(50NOT NULL default '',
  
ip varchar(20NOT NULL default '',
  
browser varchar(150NOT NULL default '',
  
PRIMARY KEY  (id)
ENGINE=HEAP
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

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

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

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

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



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

הדף נוצר ב 0.07 שניות עם 10 שאילתות

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

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