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

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

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 27-08-08, 23:38   # 1
Avi Salama
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Sep 2007
הודעות: 353

Avi Salama לא מחובר  

עבודה עם סיישן, לא מצליח

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

נתחיל מהדף login, שאותו עשיתי עם סיישן.
PHP קוד:
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<
tr>
<
form name="form1" method="post" action="checklogin.php">
<
td>
<
table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<
tr>
<
td colspan="3"><strong>Member Login </strong></td>
</
tr>
<
tr>
<
td width="78">Username</td>
<
td width="6">:</td>
<
td width="294"><input name="myusername" type="text" id="myusername"></td>
</
tr>
<
tr>
<
td>Password</td>
<
td>:</td>
<
td><input name="mypassword" type="text" id="mypassword"></td>
</
tr>
<
tr>
<
td>&nbsp;</td>
<
td>&nbsp;</td>
<
td><input type="submit" name="Submit" value="Login"></td>
</
tr>
</
table>
</
td>
</
form>
</
tr>
</
table
הדף checklogin.php:
PHP קוד:
<?php
$host
="localhost"// Host name 
$username="zvaim_new"// Mysql username 
$password="000000"// Mysql password 
$db_name="zvaim_new"// Database name 
$tbl_name="members"// Table name 

// Connect to server and select databse.
mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername stripslashes($myusername);
$mypassword stripslashes($mypassword);
$myusername mysql_real_escape_string($myusername);
$mypassword mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:index.php");
}
else {
echo 
"Wrong Username or Password";
}
?>
הדף logout.php
PHP קוד:
<? 
session_start
();
session_destroy();
?>
והדף הראשי של המערכת (מה שאני רוצה לעשות שאם אני לא מחובר אל המערכת, אז לא יהיה ניתן להכנס לדף הראשי של המערכת, אלא הוא יעביר אותי אוטומטית אל הדף login.php.

index.php - הדף הראשי של המערכת
PHP קוד:
<? 
session_start
();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="rtl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>CMS</title>
</head>
<body>

            <div class="wrep">
                <div id="header">
                      <img src="images/bar.png" width="900" height="130" alt="" />

                <div id="menu">    
                          <div class="menu_text">
                          <a href="index.html">דף ראשי</a>
                                                                                                            <br />
                                                                                                            <a href="edit.php">עריכת דפים</a>
                                                                                                            <br />
                                                                                                            <a href="edit.php">עריכת חבילות</a>
                                                                                                            <br />
                                                                                                            <a href="logout.php">התנתק</a>
                          </div>
                </div>
            </div>

                                                                       <div id="tail_right">
                        <div class="title_text" style="margin-top: 15px;">
                                                                                                             ברוך הבא<br />
                                                                                </div>
                                                                       </div>

           </div>

</body>
</html>
__________________
בברכה - אבי,
מסנג'ר: avi1_2_1@walla.com
  Reply With Quote
ישן 27-08-08, 23:40   # 2
dabi
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Dec 2007
הודעות: 1,767

dabi לא מחובר  

מה בידיוק אתה לא מצליח?
כשאתה מתחבר זה עובד?
כשאתה מתנתק?
בבקשה פרט
  Reply With Quote
ישן 28-08-08, 10:36   # 3
Erez | TrustMedia.co.il
עסק רשום [?]
 
מיני פרופיל
תאריך הצטרפות: Jul 2008
הודעות: 1,854

Erez | TrustMedia.co.il לא מחובר  

לא רשמת בראש העמוד check_login את הפונקציה session_start
  Reply With Quote
ישן 28-08-08, 11:17   # 4
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

ציטוט:
נכתב במקור על ידי EAStyle צפה בהודעה
לא רשמת בראש העמוד check_login את הפונקציה session_start
HTML קוד:
If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.
ולנושא - מה הבעייה?
  Reply With Quote
ישן 30-08-08, 01:38   # 5
NoWaySkill
חבר חדש
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
הודעות: 6

NoWaySkill לא מחובר  

תרשום
PHP קוד:
// this start the session
session_start(); 

אחי ד"א מומלץ שתצפין את הסיסמאות שלך כן ובמיוחד אם אתה בונה CMS..
תעשה ככה:
PHP קוד:
sha1($password); 
ותאחסן תסיסמא במסד ככה יותר מאובטח
  Reply With Quote
ישן 30-08-08, 10:10   # 6
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

ציטוט:
נכתב במקור על ידי NoWaySkill צפה בהודעה
תרשום
PHP קוד:
// this start the session
session_start(); 

אחי ד"א מומלץ שתצפין את הסיסמאות שלך כן ובמיוחד אם אתה בונה CMS..
תעשה ככה:
PHP קוד:
sha1($password); 
ותאחסן תסיסמא במסד ככה יותר מאובטח
זה לא יעזור לו, אף אחד לא מקדיש דקה לקרוא?
  Reply With Quote
ישן 30-08-08, 11:31   # 7
ibmod
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 1,256

ibmod לא מחובר  

הנה:
PHP קוד:

if(isset($_SESSION['myusername']))  //האם יש סיישן
{
// פה יופיע הדף כאשר אתה מחובר
} else {
// פה יופיע משהו במידה ואתה לא מחובר

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

Last edited by ibmod; 30-08-08 at 11:42..
  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. הזמן כעת הוא 05:25.

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