1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | <?php include('cfg.php');//database connection ?> <html> <head> <title>Register an Account</title> </head> <body> <?php if (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they supposed to, passwords matched, username isn't already taken, etc. */ if (!$_POST['uname'] | !$_POST['passwd'] | !$_POST['passwd_again'] ) { die('You did not fill in a required field.'); } // check if username exists in database. if (!get_magic_quotes_gpc()) { $_POST['uname'] = addslashes($_POST['uname']); } $query = "SELECT user FROM gebruikers WHERE user = '".$_POST['uname']."'"; $name_check = mysql_query($query); $name_checkk = mysql_num_rows($name_check); if ($name_checkk != 0) { die('Sorry, the username: <strong>'.$_POST['uname'].'</strong> is already taken, please pick another one.'); } // check passwords match if ($_POST['passwd'] != $_POST['passwd_again']) { die('Passwords did not match.'); } // no HTML tags in username, website, location, password $_POST['uname'] = strip_tags($_POST['uname']); $_POST['passwd'] = strip_tags($_POST['passwd']); // now we can add them to the database. // encrypt password $_POST['passwd'] = md5($_POST['passwd']); if (!get_magic_quotes_gpc()) { $_POST['passwd'] = addslashes($_POST['passwd']); } $insert = "INSERT INTO users (user, password) VALUES ('".$_POST['uname']."', '".$_POST['passwd']."')"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you, your information has been added to the database, you may now <a href="login.php" title="Login">log in</a>.</p> <?php } else { // if form hasn't been submitted ?> <h1>Register</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" border="1" cellspacing="0" cellpadding="3"> <tr><td>Username*:</td><td> <input type="text" name="uname" maxlength="40"> </td></tr> <tr><td>Password*:</td><td> <input type="password" name="passwd" maxlength="50"> </td></tr> <tr><td>Confirm Password*:</td><td> <input type="password" name="passwd_again" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Sign Up"> </td></tr> </table> </form> <?php } ?> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | <?php // database connect script. include('cfg.php'); if($logged_in == 1) { die('You are already logged in, '.$_SESSION['user'].'.'); } ?> <html> <head> <title>Login</title> </head> <body> <?php if (isset($_POST['submit'])) { // if form has been submitted /* check they filled in what they were supposed to and authenticate */ if(!$_POST['uname'] | !$_POST['passwd']) { die('You did not fill in a required field.'); } // authenticate. if (!get_magic_quotes_gpc()) { $_POST['uname'] = addslashes($_POST['uname']); } $query = "SELECT user, password FROM users WHERE user = '".$_POST['uname']."'"; $check = mysql_query($query); if (mysql_num_rows($check) == 0) { die('That username does not exist in our database.'); } $info = mysql_fetch_row($check); // check passwords match $_POST['passwd'] = stripslashes($_POST['passwd']); $info['password'] = stripslashes($info['password']); $_POST['passwd'] = md5($_POST['passwd']); if ($_POST['passwd'] != $info['password']) { die('Incorrect password, please try again.'); } // if we get here username and password are correct, //register session variables and set last login time. $_POST['uname'] = stripslashes($_POST['uname']); $_SESSION['username'] = $_POST['uname']; $_SESSION['password'] = $_POST['passwd']; ?> <h1>Logged in</h1> <p>Welcome back <?php echo $_SESSION['username']; ?>, you are logged in.</p> <?php } else { // if form hasn't been submitted ?> <center><h1>Login</h1><center> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table align="center" border="1" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td> <input type="text" name="uname" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="passwd" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 | <?php function link_weergave ($srt,$cat,$sub,$kr,$dp){ $query = "SELECT link, type, plaatje FROM links WHERE catid='$cat' AND subid='$sub' AND kolrij='$kr' "; $result = mysql_query($query); if(!$query){ // hier wordt een speciale tabel weergegeven } else{ // hier worden de waarden in een tabel weergegeven } ?> |
1 | if(!$query){ |
1 | if(!$result){ |
1 | if(!$result){ |
1 | if (mysql_num_rows($result) > 0){ |
Owja, stom. Dit zou wel moeten werken:quote:Op donderdag 29 september 2005 19:28 schreef uppie83 het volgende:
@Light
Ook met
[ code verwijderd ]
werkt het niet.
[ code verwijderd ]
heb ik ook al geprobeerd, maar om een of andere vage reden krijg ik dan overal de tabel te zien om een nieuwe entry aan te maken, behalve bij de missende entry, daar wordt de weergave tabel neergezet met lege strings.
1 | if (mysql_num_rows($result) == 0){ |
1 2 3 4 5 | $passwd = md5($_POST['passwd']); if ($passwd != $info['password']) { die('Incorrect password, please try again.'); } |
1 2 3 | if (!get_magic_quotes_gpc()) { $_POST['uname'] = addslashes($_POST['uname']); } |
1 2 3 | if (!get_magic_quotes_gpc()) { $_POST['passwd'] = addslashes($_POST['passwd']); } |
1 2 3 4 5 6 7 8 9 | $_POST['passwd'] = stripslashes($_POST['passwd']); $info['password'] = stripslashes($info['password']); $_POST['passwd'] = md5($_POST['passwd']); echo $POST['passwd']."<----->".$info['passwd']; if ($_POST['passwd'] != $info['password']) { die('Incorrect password, please try again.'); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $query = "SELECT user, password FROM users WHERE user = '".$_POST['uname']."'"; $check = mysql_query($query); if (/*DB::isError($check) ||*/ mysql_num_rows($check) == 0) { die('That username does not exist in our database.'); } $info = mysql_fetch_row($check); // check passwords match echo $info['password']."<br>"; //$_POST['passwd'] = stripslashes($_POST['passwd']); $info['password'] = stripslashes($info['password']); $_POST['passwd'] = md5($_POST['passwd']); echo $_POST['passwd']."<----->".$info['password']; if ($_POST['passwd'] != $info['password']) { die('Incorrect password, please try again.'); } |
quote:mysql_fetch_row -- Get a result row as an enumerated array
|
Forum Opties | |
---|---|
Forumhop: | |
Hop naar: |