Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this:</p> <p><del>Important use <strong>mysql_real_escape_string</strong> on all USER INPUT, or you could hacked very easily</del> SEE comment from Dan Kanze. But its better to learn the MYSQLI extension Prepared Statements, its easier cleaner and securer Here a example. <a href="http://mattbango.com/notebook/web-development/prepared-statements-in-php-and-mysqli/" rel="nofollow">http://mattbango.com/notebook/web-development/prepared-statements-in-php-and-mysqli/</a></p> <p>Also this code is not very secure, cause a user can set $_GET['is_logged_in'] !== "1" manuell, you should maybe add a cookie to the user pc, with a unique value, that the user is logged in and that value matches his user/pass pair, which you store in your DB..</p> <p>Just google secure login form php or something like that.</p> <pre><code> &lt;?php require "dbconn.php"; if(@$_GET['showerror'] == "1"){ echo "Your login has failed. Try again"; exit; } if(!empty($_POST['username']){ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql = "SELECT * FROM person WHERE name ='".$username."' AND password='".$password."'"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array( $result ); if(!empty($row)){ $_SESSION['username'] = $row['name']; header("Location: index.html?is_logged_in=1?"; exit(); }else{ header("Location: index.html?showerror=1"); exit(); } } if(@$_GET['is_logged_in'] !== "1"){ // DISPLAY FORM }else{ // DO YOUR STUFF } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload