2011-10-17 24 views
0

我正在嘗試將Cookie添加到瀏覽器。它給我參數1錯誤和參數3.此代碼在我的網站上的其他地方工作,但不在這裏。有人能幫我嗎?正在嘗試使用Cookie創建登錄

if ((!isset($_POST["uname"])) || (!isset($_POST["password"]))) 
{ 
    header ("Location: wddnt/clients/'. $tattoo_extern_acct . '/index.html"); 
    exit; 
} 

$userpass = md5($_POST['password']); 
@$db = mysqli_connect("$dbc_ser", "$dbc_usr", "$dbc_pwd", "$dbc_db"); 
$sql = "SELECT id, name, company, job_title, cell_num, office_num, office_email, 
       login_right, first_run, attempts, locked_out FROM login 
     WHERE email = '".$_POST["email"]."' 
     AND password = PASSWORD('$userpass')"; 

if (mysqli_connect_errno()) 
{ 
    echo 'Cannot connect to database: ' . mysqli_connect_error(); 
} 
else 
{ 
    $result = mysqli_query($db, $sql); 

    while ($info = mysqli_fetch_array($result)) 
    { 
    $id = stripslashes($info['id_files']); 
    $u_acct = stripslashes($info['uname']); 
    $name = stripslashes($info['name']); 
    $job_title = stripslashes($info['job_title']); 
    $location = stripslashes($info['company']); 
    $cell_num = stripslashes($info['cell_num']); 
    $office_num = stripslashes($info['office_num']); 
    $office_email = stripslashes($info['office_email']); 
    $login_right = stripslashes($info['login_right']); 
    $first_run = stripslashes($info['first_run']); 
    $attempts = stripslashes($info['attempts']); 
    $locked_out = stripslashes($info['locked_out']); 
    $land_page = stripslashes($info['land_page']); 
    } 
} 
+0

更多詳情,您可以添加整個錯誤到你的問題。 –

回答

0

嘗試調試一些個別變量。例如,什麼是$ sql?這是對的嗎?

執行了「無法連接」條款,還是得到它的查詢和失敗嗎? (我不確定「參數1錯誤和參數3」是什麼意思)。

不要忘記的方式來逃避「電子郵件」值 - 該代碼中有一個SQL注入漏洞。

0

header(「Location:wddnt/clients /'。$ tattoo_extern_acct。'/index.html」);

這是行不通的你期望的方式。

$ SQL = 「SELECT ID,姓名,公司,JOB_TITLE,cell_num,office_num,office_email, login_right,first_run,嘗試,locked_out FROM登錄 WHERE電子郵件=「」。$ _ POST [ 「電子郵件」。 「」

您需要在SQL注入閱讀起來。

而($信息= mysqli_fetch_array($結果))

您允許多個帳戶使用相同的電子郵件地址/密碼?????

它給我的參數1個錯誤和參數3

你不能發佈實際錯誤信息你?

$ id = stripslashes($ info ['id_files']);

跆拳道? Smartquotes?

0

我不知道我理解你的問題,但我最後一次檢查誰想要使用Cookie使用$ _COOKIE全局變量,無論是將它們設置或訪問它們。 $ _POST是從表單中獲取東西,而不是cookies。 請檢查手冊約$ _COOKIE 問候