Jump to content

andyg666

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

andyg666's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. an HTML form $username = $_POST['username'];
  2. i fixed it like by getting rid of the $data and $result and just setting $_SESSION with the $username variable. it works, but is this a viable and secure solution? [code] if($error == "")   {       // $data = mysql_fetch_array($result);       // $_SESSION['username'] = $data['username'];       $_SESSION['username'] = $username;       $utime = date("Y/m/d, H:i:s");        mysql_query("UPDATE users SET LastLogin='".$utime."' WHERE UserName='".$username."'");       echo '<meta http-equiv="Refresh" Content="20; URL=index.php"><BR>       Thank you for logging in, '.$_SESSION['username'].'.';       setcookie("user", $_SESSION['username'], time()+3600);   }[/code]
  3. no i'm using xxamplite. should i see if there are any upgrades or patches available? maybe it's a firewall problem? PHP Version 5.1.4
  4. ok, did that. the original error message is still there and it's not setting the cookie. this is weird because it was working in the past. all i didnt was change the database name in the connect.php file and some of the field names in the script itself. i'm wondering why it now requires all of this fixing... thanks for your help, by the way.
  5. it's removed. now i get 2 errors... [quote] Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampplite\htdocs\thebeathub\login.php:38) in C:\xampp\xampplite\htdocs\thebeathub\login.php on line 39 Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 [/quote]
  6. [quote author=complex05 link=topic=118746.msg485477#msg485477 date=1166200583] remove die(); from your script. [/quote] D'OH!! thanks.
  7. I have adapted one of the user registration and login scripts i found here. I set it up months ago, and now I have a real project to apply it to. It was working fine many months ago, but now I'm getting the following error when i attempt to login: [quote]Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0[/quote] here is the code: [code]<?php session_start(); require_once('connect.php'); if(isset($_POST['login'])) {   $error = '';   $username = $_POST['username'];   $password = $_POST['password'];   if($username == "" || $password == "")   {       $error .= 'A required field was left blank.<br />';   }   $password = md5($password);   if(get_magic_quotes_gpc())   {       $username = $username;   }   else   {       $username = addslashes($username);   }   $result = mysql_query("SELECT * FROM users WHERE UserName='".$username."' AND UserPWD='".$password."'")   or die(mysql_error());     $valid_login = mysql_num_rows($result);   if($valid_login == 0)   {       $error .= "The supplied username and/or password was incorrect.<br />";   }   if($error == "")   {       $data = mysql_fetch_array($result);       $_SESSION['username'] = $data['username'];       $utime = date("Y/m/d, H:i:s");        mysql_query("UPDATE users SET LastLogin='".$utime."' WHERE UserName='".$username."'");       echo '<meta http-equiv="Refresh" Content="5; URL=index.php"><BR>       Thank you for logging in, '.$_SESSION['username'].'.';       die();       setcookie("user", $_SESSION['username'], time()+3600);   }   else{       echo 'The following errors were returned:<br />'.$error.'<br />';       echo $username.', '.$password;   } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Log In</title> <style type="text/css"> .container {   text-align: center;   border: 1px solid #000000;   width: 300px; } td {   text-align: left; } </style> </head> <body> <form action="login.php" method="post"> <table class="container" align="center" cellspacing="0" cellpadding="0">   <tr>       <td colspan="2" style="text-align:center;"><h1>Log In</h1></td>   </tr>   <tr>       <td>Username:</td>       <td><input type="text" name="username" maxlength="20" /></td>   </tr>   <tr>       <td>Password:</td>       <td><input type="password" name="password" /></td>   </tr>   <tr>       <td colspan="2" style="text-align:center;"><input name="login" type="submit" value="Log In" /></td>   </tr>   <tr>       <td colspan="2" style="text-align:center;"><a href="register.php">Register</a> | <a href="index.php">Index</a></td>   </tr> </table> </form> </body> </html> [/code] it IS updating the lastlogin field. but it doesn't set the cookie. what global variable is it talking about? and how can i fix this? thanks.
  8. changing the last two lines to this: [code]CreationDate datetime NOT NULL default '0000-00-00 00:00:00', ModifyDate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP )"; [/code] did the trick. thanks.
  9. i copied them directly from the tutorials at w3schools.com. i've actually tried it without them ( just datetime() ) and i get the same error message. let me try it one more time and i'll report back. thanks.
  10. if i'm not mistaken, and i could be, the proper syntax is... [code]$query = "UPDATE news SET news_content=".$content."";[/code]
  11. I'm using XAMPP, with PHP 5 and MySQL 5. I have created a database and I am attempting to use the following PHP code to create tables: [code]mysql_select_db("my_db", $con); $sql = "CREATE TABLE tblActivity ( ActivityID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(ActivityID), LocationID int, ActivityType varchar(15), Accessibility text, Popularity int(2), AvgPopulation int(7), Keywords text, Description text, CreatedBy varchar(15), CreationDate datetime(yyyy-mm-dd hh:mm:ss), ModifyDate datetime(yyyy-mm-dd hh:mm:ss) )"; $result = mysql_query($sql,$con); if (!$result)   {   die("Could not create tblActivity: " . mysql_error() . "<BR>");   }   else   {   echo "Creating tblActivity...<br>";   } [/code]  This code returns the following error message: [quote]"Could not create tblActivity: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(yyyy-mm-dd hh:mm:ss), ModifyDate datetime(yyyy-mm-dd hh:mm:ss) )' at line 13" [/quote] I'm not sure what is incorrect--I've checked this against tons of examples and tutorials. I can't find any errors in the syntax. Any ideas? Thanks!
×
×
  • 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.