Help - Search - Members - Calendar
Full Version: php mysql login
ieXbeta Board > Tech > Developer Center
Dutch2005
CODE
<?php
$mysql_link = mysql_connect("server", "users", "pass");
mysql_select_db($db, $mysql_link);
if (($username) AND ($password)) {
  // you should inspect these variables before passing off to mySQL
   $query = "SELECT email, wachtwoord FROM shop ";
   $query .= "WHERE email='$username' AND wachtwoord='$password'";
   $result = mysql_query($query, $mysql_link);
     if(mysql_num_rows($result)) {
       // we have at least one result, so update the logged in datetime
       $query = "UPDATE from login SET logged=SYSDATE()";
       $query .= "WHERE email='$username' AND wachtwoord='$password' ";
      mysql_query($query,$mysql_link);
     } else {
       print("Sorry, this login is invalid.");
       exit;
     }
} else {
  print ("<form action=\"$PHP_SELF\" method=\"POST\">");
#  print ("Gebruikersnaam / E-mail: <input type="text" name="username">");
#  print ("Wachtwoord: <input type="password" name="password">");
#  print ("<input type="submit" value="Submit"></form>");
}
?>




well i get a error @ the lines that i placed a # infront


any suggestion on how to fix this?


yet i have totally no idea what could be wrong atm...

Dutch2005
ok th following code does work

CODE

<?php
$mysql_link = mysql_connect("server", "user", "pass");
mysql_select_db($db, $mysql_link);
if (($username) AND ($password)) {
  // you should inspect these variables before passing off to mySQL
   $query = "SELECT email, wachtwoord FROM shop ";
   $query .= "WHERE email='$username' AND wachtwoord='$password'";
   $result = mysql_query($query, $mysql_link);
     if(mysql_num_rows($result)) {
       // we have at least one result, so update the logged in datetime
       $query = "UPDATE from login SET logged=SYSDATE()";
       $query .= "WHERE email='$username' AND wachtwoord='$password' ";
      mysql_query($query,$mysql_link);
     } else {
       print("Sorry, this login is invalid.");
       exit;
     }
} else {
print ("<form action=\"$PHP_SELF\" method=\"POST\">");
print ("GebruikersNaam - E-mail: <input type=\"text\" name=\"username\">");
#  Dit komt uit dreamweaver. print ("Email: <input id="username" name="username" type="text" size="25" />");
print ("Wachtwoord: <input type= \"password\" name=\"password\">");
#  Dit komt uit dreamweaver. print ("Wachtwoord:  <input id="password" name="password" type="password" size="25" />");
print ("<input type=\"submit\" value=\"Submit\"></form>");
}
?>


hope this helps any one (forgot to use the \ ;-)
quantumAlpha
yeah, escaped quotes suck unless you're using a decent PHP editor. Zend is worth it (the editor part i mean)
Dutch2005
most anoying part reallyw as that, i copied it form a php coding site (so you think its correct, yet this time not...)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.