Jump to content

johnharris

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johnharris's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have an upload script written in php for uploading images etc. It works fine in firefox, however not in IE.... [code] if (isset($_FILES['uploadedphoto'])) { $targetpath = "images/photos/profiles"; if (($_FILES["uploadedphoto"]["type"] == "image/gif") || ($_FILES["uploadedphoto"]["type"] == "image/jpeg") && ($_FILES["uploadedphoto"]["size"] < 700000)) { if ($_FILES["uploadedphoto"]["error"] > 0) {     echo "Return Code: " . $_FILES["uploadedphoto"]["error"] . ". Profile photo was not uploaded.<br />";     } else {     if (file_exists($targetpath . "/" . $_FILES["uploadedphoto"]["name"])) {         echo $_FILES["uploadedphoto"]["name"] . " already exists. Profile photo was no uploaded";       } else {           if (move_uploaded_file($_FILES["uploadedphoto"]["tmp_name"], $targetpath . "/" . $_FILES["uploadedphoto"]["name"])) { $completeurl = $targetpath . "/" . $_FILES["uploadedphoto"]["name"]; $query = "UPDATE users SET pic_url='$completeurl' WHERE username='$u'"; $result = @mysql_query($query); if (!$result) { echo 'Profile photo was not uploaded.'; } } else { echo 'Profile photo was not uploaded.'; }       }     } } else {   echo "Invalid profile photo - file size too big (must be under 700kb) / wrong file type (must be jpeg or gif)";   } } [/code] As i said, in firefox it works fine, in IE the "else" statement of the ... "if (($_FILES["uploadedphoto"]["type"] == "image/gif") || ($_FILES["uploadedphoto"]["type"] == "image/jpeg") && ($_FILES["uploadedphoto"]["size"] < 700000)) {" ... is called.
  2. I've looked around for anyone with the same problem and I can't see any solution so I decided to post. I have created this login form and it all works fine. I then added cookie support and that also worked. However, I cannot make it so that a cookie expires when the browser is closed. I have used a checkbox "remember_me" in the form, and have tested that it works ok (see the commented out echo statements in the submit section). If I login and no not check the button, then close the browser, then re-open, I am still logged in. I thought if no value for expiry was specified cookies expired on session (browser) close? Mine do not seem to be :( Below is login.php [code] <?php         if (isset($_POST['submit']))    {             require_once ('../mysql_connect.php');                 function escape_data ($data)    {                     global $dbc;                         if (ini_get('magic_quotes_gpc'))    {                             $data = stripslashes($data);                         }                         return mysql_real_escape_string($data, $dbc);                     }                 $message = NULL;                 if (empty($_POST['username']))    {                     $u = FALSE;             $message .= '<p>You forgot to enter your username!</p>';                     } else    {                     $u = escape_data($_POST['username']);                     }                 if (empty($_POST['password']))    {                     $p = FALSE;             $message .= '<p>You forgot to enter your password!</p>';                     } else    {                     $p = escape_data($_POST['password']);                     }                 if ($u && $p)    {                         $query = "SELECT user_id, first_name FROM users WHERE username='$u' AND password=MD5('$p')";             $result = @mysql_query ($query);             $row = mysql_fetch_array ($result, MYSQL_NUM);                         if ($row)    {                                 if (isset($_POST['remember_me']))    {                                         setcookie ('first_name', $row[1], time()+36000, '/', '', 0);                     setcookie ('user_id', $row[0], time()+36000, '/', '', 0);                     header ("Location: index.php");                     //echo '<p>ticked</p>';                                     } else    {                                     setcookie ('first_name', $row[1], NULL, '/', '', 0);                     setcookie ('user_id', $row[0], NULL, '/', '', 0);                     header ("Location: index.php");                     //echo '<p>Not ticked</p>';                                     }                             } else    {                             $message = '<p>Error. Your username/password is incorrect.</p>';                             }                         mysql_close();                                 } else    {                     $message .= '<p>Please try again.</p>';                     }             }         if (isset($message))    {             echo $message;             } ?> <form action="<?php echo $_SERVER['DOCUMENT_ROOT/index.php']; ?>" method="post">     <p>Username: <input type="text" name="username" size="15" maxlength="20" value="<?php if (isset($_POST['username']))     echo $_POST['username']; ?>" /></p>     <p>Password: <input type="password" name="password" size="15" maxlength="20" /></p>         <input type="checkbox" name="remember_me" /> Keep me logged in (requires cookies to be enabled)     <div align="center"><input type="submit" name="submit" value="Login" /></div>     </form> [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.