/*This is were the actual log in takes place. We tell mysql to select the ID where the Name is exactly like the Name from the Form where is Password is exactly like the encryption values of the password from the form.*/ $sql = "SELECT ID FROM " . $Table . " WHERE Name='" . addslashes($_POST['Name']) . "' AND Password='" . md5($_POST['Password']) . "' LIMIT 1"; if(!($result = mysql_query($sql))) die(mysql_error());
/*This is were we check the result. We check to see how many rows were in the result of the query. If there is 1 one row in the result, that means there is one username with the right information, so that would mean they are logged in.*/ if(mysql_num_rows($result) == 1) { /*Here we set a cookie that tells if the user has logged in and set it to last for a day. The cookie is used on the members page to check If they cookie is there they can see the page, if not they can't.*/
setcookie("LoggedIn, TRUE, time()+(3600 * 24));
/*You could also do the header() here just like I explained before.*/ echo "Continue to the <a href=members.php>Members</a> page."; } else { echo "Login failure"; } ?>
Efter registreing af et brugernavn samt password bliver man sendt videre til logindelen derefter skulle man så gå til den beskyttede side, men der kommer altså fejl i login.php linie 22 og det er den du ser her.
<?php /* Include the DB connection Parameters */ include("common.php");
/*Connect to the DB using the info in common.php*/ if(!($link_id = mysql_connect($Host, $User, $Pass))) die(mysql_erorr()); mysql_select_db($DB);
/*Here is where the actual work is done. We add slashes to the username to prevent errors in the query. Then we encrypt the password. This password is NEVER decryptable. Never, so users can have a sense of security. We insert, and then we say they are registered. The Period as joins the strings togther, so we can join the returns of fucntions to that string without creating a new variable foreach one.*/ $sql = "INSERT INTO " . $Table . " VALUES('', '" . addslashes($_POST['Name']) . "', '" . md5($_POST['Password']) . "')"; if(!($result = mysql_query($sql))) { die(mysql_error()); } else { /*You can redirect them instead of just giving them a link, to do this: you would replace the code below with header("location: login.html"); Be warned, you can't send headers after text is outputted, so if you wanted to have the message, and have them be forwareded, you would have to put the function ob_start() at the very first line of this file, and call ob_end_flush() at the very end.*/ echo "Your user account has been created!<br>"; echo "<a href=login.html>Continues</a> to the login page"; }
Warning: Cannot add header information - headers already sent by (output started at /usr/www/borbjerg-sk_dk/public_html/common.php:13) in /usr/www/borbjerg-sk_dk/public_html/login.php on line 18 Continue to the Members page.
Ja det er fordi at du udskriver html før din session_register(); det må man ikke.
Jeg kan ikke se din session_register(); men den må næsten ligge i common.php
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.