Jump to content

aled2305

Recommended Posts

Hello, okay, so I need some help, before i start i must warn you that i'm not very good at explaining.
 
Using a WYSIWYG Web Builder i have built a website with a membership system.
 
Now when i make an account with the membership system, and enter the password 'htmlforums' it will show '2810bd8735116c769d9d4f6d6b53c3e1' in my mySQL database.
 
Now I have also downloaded a forum script and have linked the two to the same database. The only problem is that the user password is different and therefore both don't work with one user. 
 
If make an account with the same password using the forums script it will show '2a9e532f806c272ecb01d58c503bc9a96f7b3ad8' in my mySQL database under passowrd.
 
So both use a different system to login, but if i manually change the password's in the database (swap them) they will work, (as in with password one (2810bd8735116c769d9d4f6d6b53c3e1), i can sign in to the site and if i change it password 2 (2a9e532f806c272ecb01d58c503bc9a96f7b3ad8) i can sign in to the forum) so i'm not far off.
 
I have very little knowledge of how they work, so can someone help me to get them both generating and accepting the same password.
 
P.S I can't edit the code from the WYSIWYG web builder, as it generates it automatically.  
 
Here is the code for the login page by the WYSIWYG Web Builder.
 
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'loginform')
{
session_start();
$success_page = isset($_SESSION['page_from'])?$_SESSION['page_from']:'/../../library/';
   $error_page = basename(__FILE__);
   $mysql_server = 'localhost';
   $mysql_username = '???????';
   $mysql_password = '???????';
   $mysql_database = '???????';
   $mysql_table = 'USERS';
   $crypt_pass = md5($_POST['password']);
   $found = false;
   $fullname = '';

   $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
   if (!$db)
   {
      die('Failed to connect to database server!<br>'.mysql_error());
   }
   mysql_select_db($mysql_database, $db) or die('Failed to select database<br>'.mysql_error());
   $sql = "SELECT password, fullname, active FROM ".$mysql_table." WHERE username = '".mysql_real_escape_string($_POST['username'])."'";
   $result = mysql_query($sql, $db);
   if ($data = mysql_fetch_array($result))
   {
      if ($crypt_pass == $data['password'] && $data['active'] != 0)
      {
         $found = true;
         $fullname = $data['fullname'];
      }
   }
   mysql_close($db);
   if($found == false)
   {
      header('Location: '.$error_page);
      exit;
   }
   else
   {
      if (session_id() == "")
      {
         session_start();
      }
      $_SESSION['username'] = $_POST['username'];
      $_SESSION['fullname'] = $fullname;
      $rememberme = isset($_POST['rememberme']) ? true : false;
      if ($rememberme)
      {
         setcookie('username', $_POST['username'], time() + 3600*24*30);
         setcookie('password', $_POST['password'], time() + 3600*24*30);
      }
      header('Location: '.$success_page);
      exit;
   }
}
$username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
$password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
<meta name="description" content="Login page for Techyoucation.com">
<meta name="keywords" content="techyoucation, tutorials, technology, under construction,">
<meta name="author" content="Aled Daniel Evans">
<meta name="categories" content="Technology, Tutorials">
<link rel="shortcut icon" href="icon.ico">
<link rel="stylesheet" href="Site.css" type="text/css">
<link rel="stylesheet" href="index.css" type="text/css">
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="wb.stickylayer.min.js"></script>
<script type="text/javascript" src="jquery.effects.core.min.js"></script>
<script type="text/javascript" src="jquery.effects.blind.min.js"></script>
<script type="text/javascript" src="jquery.effects.bounce.min.js"></script>
<script type="text/javascript" src="jquery.effects.clip.min.js"></script>
<script type="text/javascript" src="jquery.effects.drop.min.js"></script>
<script type="text/javascript" src="jquery.effects.explode.min.js"></script>
<script type="text/javascript" src="jquery.effects.fold.min.js"></script>
<script type="text/javascript" src="jquery.effects.highlight.min.js"></script>
<script type="text/javascript" src="jquery.effects.pulsate.min.js"></script>
<script type="text/javascript" src="jquery.effects.scale.min.js"></script>
<script type="text/javascript" src="jquery.effects.shake.min.js"></script>
<script type="text/javascript" src="jquery.effects.slide.min.js"></script>
<script type="text/javascript" src="../../searchindex.js"></script>
<script type="text/javascript">
<!--
var features = 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,left=,top=,width=,height=';
var searchDatabase = new SearchDatabase();
var searchResults_length = 0;
var searchResults = new Object();
function searchPage(features)
{
   var element = document.getElementById('search_box_keyword');
   if (element.value.length != 0 || element.value != " ")
   {
      var value = unescape(element.value);
      var keywords = value.split(" ");
      searchResults_length = 0;
      for (var i=0; i<database_length; i++)
      {
         var matches = 0;
         var words = searchDatabase[i].title + " " + searchDatabase[i].description + " " + searchDatabase[i].keywords;
         for (var j = 0; j < keywords.length; j++)
         {
            var pattern = new RegExp(keywords[j], "i");
            var result = words.search(pattern);
            if (result >= 0)
            {
               matches++;
            }
            else
            {
               matches = 0;
            }
         }
         if (matches == keywords.length)
         {
            searchResults[searchResults_length++] = searchDatabase[i];
         }
      }
      var wndResults = window.open('about:blank', '', features);
      setTimeout(function()
      {
         var html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Search results<\/title><\/head>';
         html = html + '<body style="background-color:#FFFFFF;margin:0;padding:2px 2px 2px 2px;">';
         html = html + '<span style="font-family:Arial;font-size:13px;color:#000000">';
         for (var n=0; n<searchResults_length; n++)
         {
            html = html + '<b><a style="color:#0000FF" target="_parent" href="'+searchResults[n].url+'">'+searchResults[n].title +'<\/a><\/b><br>Description:' + searchResults[n].description + '<br>Keywords:' + searchResults[n].keywords +'<br><br>\n';
         }
         if (searchResults_length == 0)
         {
            html = html + 'No results';
         }
         html = html + '<\/span>';
         html = html + '<\/body><\/html>';
         wndResults.document.write(html);
     },100);
   }
   return false;
}
// -->
</script>
<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script src="cookieControl-5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">//<![CDATA[
  cookieControl({
      introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>',
      fullText:'<p>Some of these cookies are essential to make our site work and have already been set. Others help us to improve by giving us some insight into how the site is being used or help to improve the experience of using our site but will only be set if you consent.</p><p>By using our site you accept the terms of our <a href="http://www.whatnews.co.uk/privacy">Privacy Policy</a></p>',
      position:'left', // left or right
      shape:'triangle', // triangle or diamond
      theme:'light', // light or dark
      startOpen:true,
      autoHide:3000,
      subdomains:true,
      protectedCookies: ['analytics', 'twitter'], //list the cookies you do not want deleted ['analytics', 'twitter']
      consentModel:'implicit',
      onAccept:function(){ccAddAnalytics()},
      onReady:function(){},
      onCookiesAllowed:function(){ccAddAnalytics()},
      onCookiesNotAllowed:function(){},
      countries:'United Kingdom,Netherlands' // Or supply a list ['United Kingdom', 'Greece']
      });

      function ccAddAnalytics() {
        jQuery.getScript("http://www.google-analytics.com/ga.js", function() {
          var GATracker = _gat._createTracker('');
          GATracker._trackPageview();
        });
      }
   //]]>
</script>  


<script type="text/javascript" src="./wwb8.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
   $("#FB-Over a").hover(function()
   {
      $(this).children("span").stop().fadeTo(200, 0);
   }, function()
   {
      $(this).children("span").stop().fadeTo(200, 1);
   })
   $("#G-Over a").hover(function()
   {
      $(this).children("span").stop().fadeTo(200, 0);
   }, function()
   {
      $(this).children("span").stop().fadeTo(200, 1);
   })
   $("#T-Over a").hover(function()
   {
      $(this).children("span").stop().fadeTo(200, 0);
   }, function()
   {
      $(this).children("span").stop().fadeTo(200, 1);
   })
   $("#YT-Over a").hover(function()
   {
      $(this).children("span").stop().fadeTo(200, 0);
   }, function()
   {
      $(this).children("span").stop().fadeTo(200, 1);
   })
   $("#Layer3").stickylayer({orientation: 1, position: [0, 0], delay: 0});
   $("#RollOver1 a").hover(function()
   {
      $(this).children("span").stop().fadeTo(500, 0);
   }, function()
   {
      $(this).children("span").stop().fadeTo(500, 1);
   })
   $("#header_inc_layer1").stickylayer({orientation: 2, position: [0, 0], delay: 0});
   var $search = $('#search_box_form');
   var $searchInput = $search.find('input');
   var $searchLabel = $search.find('label');
   if ($searchInput.val())
   {
      $searchLabel.hide();
   }
   $searchInput.focus(function()
   {
      $searchLabel.hide();
   }).blur(function()
   {
      if (this.value == '')
      {
         $searchLabel.show();
      }
   });
   $searchLabel.click(function()
   {
      $searchInput.trigger('focus');
   });

});
</script>
<!--[if lt IE 7]>
<style type="text/css">
   img { behavior: url("pngfix.htc"); }
</style>
<![endif]-->
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<!-- end no cache headers -->

</head>
<body>
<div id="container">
<div id="wb_Shape1" style="position:absolute;left:3px;top:74px;width:994px;height:412px;z-index:66;">
<img src="images/img0010.png" id="Shape1" alt="" style="border-width:0;width:994px;height:412px;"></div>
<div id="wb_Text1" style="position:absolute;left:33px;top:103px;width:102px;height:29px;z-index:67;text-align:left;">
<span style="color:#2A2B30;font-family:Arial;font-size:24px;"><strong>Login</strong></span></div>
<hr id="Line1" style="margin:0;padding:0;position:absolute;left:30px;top:155px;width:933px;height:1px;z-index:68;">
<div id="wb_Text2" style="position:absolute;left:30px;top:166px;width:76px;height:12px;text-align:justify;z-index:69;">
<span style="color:#D9D9D9;font-family:Arial;font-size:9.3px;">PLEASE LOGIN</span></div>
<div id="wb_loginform" style="position:absolute;left:336px;top:218px;width:322px;height:214px;z-index:70;">
<form name="loginform" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform">
<input type="hidden" name="form_name" value="loginform">
<div id="wb_Text6" style="position:absolute;left:45px;top:118px;width:91px;height:16px;z-index:58;text-align:left;">
<span style="color:#666666;font-family:Arial;font-size:13px;">Remember me</span></div>
<input type="checkbox" id="rememberme" name="rememberme" value="on" style="position:absolute;left:23px;top:117px;z-index:59;">
<input type="submit" id="login_button" name="login" value="Log In" style="position:absolute;left:92px;top:148px;width:138px;height:33px;z-index:60;">
<div id="wb_Shape2" style="position:absolute;left:23px;top:16px;width:283px;height:40px;z-index:61;">
<img src="images/img0011.png" id="Shape2" alt="" style="border-width:0;width:283px;height:40px;"></div>
<div id="wb_Shape3" style="position:absolute;left:23px;top:66px;width:283px;height:40px;z-index:62;">
<img src="images/img0012.png" id="Shape3" alt="" style="border-width:0;width:283px;height:40px;"></div>
<input type="text" id="username" style="position:absolute;left:23px;top:16px;width:280px;height:38px;line-height:38px;z-index:63;" name="username" value="<?php echo $username; ?>Username" autocomplete="off">
<input type="password" id="password" style="position:absolute;left:23px;top:66px;width:280px;height:38px;line-height:38px;z-index:64;" name="password" value="<?php echo $password; ?> Password" autocomplete="off">
<div id="wb_Text3" style="position:absolute;left:83px;top:185px;width:160px;height:16px;z-index:65;text-align:left;">
<span style="color:#2A2B30;font-family:Arial;font-size:13px;"><strong>Not a member? <a href="./../register/index.php" class="Bold_Grey">Register</a></strong></span></div>
</form>
</div>

<div id="wb_Extension1" style="position:absolute;left:0px;top:0px;width:100px;height:100px;z-index:72;">
</div>
</div>
<div id="Layer2" style="position:fixed;text-align:center;left:0px;top:0px;right:0px;height:56px;z-index:73;" title="">
<div id="Layer2_Container" style="width:994px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="wb_Header_Master_Page" style="position:absolute;left:0px;top:0px;width:991px;height:56px;z-index:13;">
<div id="Layer3" style="position:absolute;text-align:right;left:0px;top:0px;width:220px;height:56px;z-index:11;" title="">
<div id="Layer3_Container" style="width:220px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="RollOver1" style="position:absolute;overflow:hidden;left:0px;top:5px;width:219px;height:47px;z-index:0">
<a href="./../../index.html" target="_top">
<img class="hover" alt="" src="images/techyoucation_grey.png" style="left:0px;top:0px;width:219px;height:47px;">
<span><img alt="" src="images/full_logo.png" style="left:0px;top:0px;width:219px;height:47px"></span>
</a>
</div>
</div>
</div>
<div id="header_inc_layer1" style="position:absolute;text-align:right;left:561px;top:0px;width:430px;height:56px;z-index:12;" title="">
<div id="header_inc_layer1_Container" style="width:430px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="signup" style="position:absolute;overflow:hidden;left:231px;top:8px;width:86px;height:41px;z-index:2">
<a href="./../register/index.php">
<img class="hover" alt="" src="images/signup-hover.png" style="left:0px;top:0px;width:86px;height:41px;">
<span><img alt="" src="images/signup-off.png" style="left:0px;top:0px;width:86px;height:41px"></span>
</a>
</div>
<div id="wb_login" style="position:absolute;left:329px;top:8px;width:86px;height:41px;z-index:3;">
<a href="./index.php" onclick="ShowObject('login_dialog', 1);return false;"><img src="images/login-small.png" id="login" alt="" border="0" style="width:86px;height:41px;"></a></div>
<div id="wb_search_dark_bg" style="position:absolute;left:134px;top:8px;width:86px;height:41px;z-index:4;">
<img src="images/search.png" id="search_dark_bg" alt="" border="0" style="width:86px;height:41px;"></div>
<div id="wb_Search-g" style="position:absolute;left:169px;top:8px;width:51px;height:41px;visibility:hidden;z-index:5;">
<img src="images/img0007.gif" id="Search-g" alt="" style="border-width:0;width:51px;height:41px;"></div>
<div id="wb_search-w" style="position:absolute;left:17px;top:8px;width:152px;height:41px;visibility:hidden;z-index:6;">
<img src="images/img0008.gif" id="search-w" alt="" style="border-width:0;width:152px;height:41px;"></div>
<div id="wb_Search_show" style="position:absolute;left:192px;top:17px;width:22px;height:22px;z-index:7;">
<a href="#" onclick="ShowObjectWithEffect('wb_search-w', 1, 'slideright', 500);ShowObject('wb_Search-g', 1);ShowObjectWithEffect('search_layer', 1, 'slideright', 500);ShowObject('wb_search_click', 1);return false;"><img src="images/icon-search-da7ca298c043e217cdaced7a129fef8f.png" id="Search_show" alt="" border="0" style="width:22px;height:22px;"></a></div>
<div id="search_layer" style="position:absolute;text-align:left;visibility:hidden;left:32px;top:7px;width:149px;height:36px;z-index:8;" title="">
<div id="wb_search_box" style="position:absolute;left:0px;top:7px;width:149px;height:27px;z-index:1;">
<form action="" name="search_box_form" id="search_box_form" accept-charset="UTF-8" onsubmit="return searchPage(features)">
<input type="text" id="search_box_keyword" style="position:absolute;left:0px;top:0px;width:149px;height:27px;line-height:27px;;" name="SiteSearch1" value="">
<label id="search_box_label" style="position:absolute;left:0px;top:7px;" for="search_box_keyword">Search this website</label>
</form>
</div>
</div>
<div id="wb_search_click" style="position:absolute;left:192px;top:17px;width:21px;height:21px;visibility:hidden;z-index:9;">
<a href="#" onclick="searchPage();return false;"><img src="images/icon-search-da7ca298c043e217cdaced7a129fef8f.png" id="search_click" alt="" border="0" style="width:21px;height:21px;"></a></div>
</div>
</div>
</div>
</div>
</div>
<div id="footer_layer" style="position:absolute;text-align:center;left:0px;top:494px;width:100%;height:258px;z-index:74;" title="">
<div id="footer_layer_Container" style="width:994px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="wb_footer_master_page" style="position:absolute;left:0px;top:0px;width:994px;height:257px;z-index:29;">
<div id="Layer" style="position:absolute;text-align:center;left:1px;top:0px;width:99%;height:257px;z-index:28;" title="">
<div id="Layer_Container" style="width:993px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="wb_logo-g" style="position:absolute;left:0px;top:12px;width:219px;height:47px;z-index:14;">
<a href="./../../under_construction/index.html"><img src="images/techyoucation%20grey.png" id="logo-g" alt="" border="0" style="width:219px;height:47px;"></a></div>
<div id="wb_mission-text" style="position:absolute;left:6px;top:72px;width:250px;height:48px;text-align:justify;z-index:15;">
<span style="color:#808080;font-family:Arial;font-size:13px;">We are on a mission, that mission is to teach everyone with the passion to learn Technology.</span></div>
<hr id="devide" style="margin:0;padding:0;position:absolute;left:8px;top:121px;width:222px;height:1px;z-index:16;">
<div id="wb_copyright-text" style="position:absolute;left:6px;top:172px;width:250px;height:48px;text-align:justify;z-index:17;">
<span style="color:#808080;font-family:Arial;font-size:13px;">© Techyoucation 2013 All trademarks and logos are the property of their respective owners!</span></div>
<div id="wb_get-in" style="position:absolute;left:751px;top:7px;width:235px;height:32px;z-index:18;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;"><strong><a href="./../../under_construction/contact_us/index.html" class="Bold_Grey">Get In Touch </a></strong></span><span style="color:#808080;font-family:Arial;font-size:13px;"><strong><a href="./../../under_construction/contact_us/index.html" class="Bold_Grey">→</a></strong></span><span style="color:#000000;font-family:Arial;font-size:13px;"><strong><br><a href="./../../legal/index.php" class="Bold_Grey">Privacy Policy / Terms Of Service</a></strong></span></div>
<div id="wb_vision-logo" style="position:absolute;left:318px;top:12px;width:162px;height:60px;z-index:19;">
<a href="http://secure.thevisionworld.com/aff.php?aff=092" target="_top"><img src="images/VisionHelpdeskLogo.png" id="vision-logo" alt="" border="0" style="width:162px;height:60px;"></a></div>
<div id="wb_Vision" style="position:absolute;left:286px;top:72px;width:230px;height:64px;text-align:justify;z-index:20;">
<span style="color:#808080;font-family:Arial;font-size:13px;">We would like to thank vision HelpDesk for supporting us with our mission by supplying us with a free copy of their amazing script.</span></div>
<div id="wb_Navaldesigns" style="position:absolute;left:286px;top:152px;width:230px;height:48px;text-align:justify;z-index:21;">
<span style="color:#808080;font-family:Arial;font-size:13px;">We would also like to thank George  <a href="http://www.dbtechnosystems.com/" class="Top_Nav">(Navaldesign)</a> for helping us with the membership system on this site.</span></div>
<div id="FB-Over" style="position:absolute;overflow:hidden;left:38px;top:134px;width:29px;height:29px;z-index:22">
<a href="https://www.facebook.com/techyoucation">
<img class="hover" alt="" src="images/icon-facebook-new-7fd375259239b05ac8f42657988e351f-over.png" style="left:0px;top:0px;width:29px;height:29px;">
<span><img alt="" src="images/icon-facebook-new-7fd375259239b05ac8f42657988e351f.png" style="left:0px;top:0px;width:29px;height:29px"></span>
</a>
</div>
<div id="G-Over" style="position:absolute;overflow:hidden;left:78px;top:134px;width:29px;height:29px;z-index:23">
<a href="https://plus.google.com/b/113434853007695128940/113434853007695128940/posts">
<img class="hover" alt="" src="images/icon-googleplus-f9e3bf613ef1807f53cc7e3c34fb9b1a-over.png" style="left:0px;top:0px;width:29px;height:29px;">
<span><img alt="" src="images/icon-googleplus-f9e3bf613ef1807f53cc7e3c34fb9b1a.png" style="left:0px;top:0px;width:29px;height:29px"></span>
</a>
</div>
<div id="T-Over" style="position:absolute;overflow:hidden;left:118px;top:134px;width:29px;height:29px;z-index:24">
<a href="https://twitter.com/techyoucation">
<img class="hover" alt="" src="images/icon-twitter-new-47502fddb8222a283378a21e5b421c2d-over.png" style="left:0px;top:0px;width:29px;height:29px;">
<span><img alt="" src="images/icon-twitter-new-47502fddb8222a283378a21e5b421c2d.png" style="left:0px;top:0px;width:29px;height:29px"></span>
</a>
</div>
<div id="YT-Over" style="position:absolute;overflow:hidden;left:158px;top:134px;width:29px;height:29px;z-index:25">
<a href="http://www.youtube.com/techyoucation">
<img class="hover" alt="" src="images/icon-youtube-a442f16454bb0a8fe31df4f93b5d8aa2-over.png" style="left:0px;top:0px;width:29px;height:29px;">
<span><img alt="" src="images/icon-youtube-a442f16454bb0a8fe31df4f93b5d8aa2.png" style="left:0px;top:0px;width:29px;height:29px"></span>
</a>
</div>
<!-- Twitter Follow -->
<div id="twitter" style="position:absolute;left:587px;top:6px;width:154px;height:47px;z-index:26">
<a href="https://twitter.com/techyoucation" class="twitter-follow-button" data-show-count="false">Follow @techyoucation</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
<div id="wb_HTML-image" style="position:absolute;left:610px;top:58px;width:99px;height:139px;z-index:27;">
<img src="images/html5_logo_small.png" id="HTML-image" alt="" border="0" style="width:99px;height:139px;"></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

and here is the login code for the forum.

<?php
//signin.php
include 'connect.php';
include 'header.php';

echo '<h3>Sign in</h3><br />';

//first, check if the user is already signed in. If that is the case, there is no need to display this page
if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
{
	echo 'You are already signed in, you can <a href="signout.php">sign out</a> if you want.';
}
else
{
	if($_SERVER['REQUEST_METHOD'] != 'POST')
	{
		/*the form hasn't been posted yet, display it
		  note that the action="" will cause the form to post to the same page it is on */
		echo '<form method="post" action="">
			Username: <input type="text" name="username" /><br />
			Password: <input type="password" name="password"><br />
			<input type="submit" value="Sign in" />
		 </form>';
	}
	else
	{
		/* so, the form has been posted, we'll process the data in three steps:
			1.	Check the data
			2.	Let the user refill the wrong fields (if necessary)
			3.	Varify if the data is correct and return the correct response
		*/
		$errors = array(); /* declare the array for later use */
		
		if(!isset($_POST['username']))
		{
			$errors[] = 'The username field must not be empty.';
		}
		
		if(!isset($_POST['password']))
		{
			$errors[] = 'The password field must not be empty.';
		}
		
		if(!empty($errors)) /*check for an empty array, if there are errors, they're in this array (note the ! operator)*/
		{
			echo 'Uh-oh.. a couple of fields are not filled in correctly..<br /><br />';
			echo '<ul>';
			foreach($errors as $key => $value) /* walk through the array so all the errors get displayed */
			{
				echo '<li>' . $value . '</li>'; /* this generates a nice error list */
			}
			echo '</ul>';
		}
		else
		{
			//the form has been posted without errors, so save it
			//notice the use of mysql_real_escape_string, keep everything safe!
			//also notice the sha1 function which hashes the password
			$sql = "SELECT 
						id,
						username,
						userlevel
					FROM
						USERS
					WHERE
						username = '" . mysql_real_escape_string($_POST['username']) . "'
					AND
						password = '" . sha1($_POST['password']) . "'";
						
			$result = mysql_query($sql);
			if(!$result)
			{
				//something went wrong, display the error
				echo 'Something went wrong while signing in. Please try again later.';
				//echo mysql_error(); //debugging purposes, uncomment when needed
			}
			else
			{
				//the query was successfully executed, there are 2 possibilities
				//1. the query returned data, the user can be signed in
				//2. the query returned an empty result set, the credentials were wrong
				if(mysql_num_rows($result) == 0)
				{
					echo 'You have supplied a wrong user/password combination. Please try again.';
				}
				else
				{
					//set the $_SESSION['signed_in'] variable to TRUE
					$_SESSION['signed_in'] = true;
					
					//we also put the id and username values in the $_SESSION, so we can use it at various pages
					while($row = mysql_fetch_assoc($result))
					{
						$_SESSION['id'] 	= $row['id'];
						$_SESSION['username'] 	= $row['username'];
						$_SESSION['userlevel'] = $row['userlevel'];
					}
					
					echo 'Welcome, ' . $_SESSION['username'] . '. <br /><a href="index.php">Proceed to the forum overview</a>.';
				}
			}
		}
	}
}

include 'footer.php';
?>

It looks like you many need the header two...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
 	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 	<meta name="description" content="A short description." />
 	<meta name="keywords" content="put, keywords, here" />
 	<title>PHP-MySQL forum</title>
	<link rel="stylesheet" href="style.css" type="text/css">
</head>
<div id="blog">
<div id="header"><a href="http://techyoucation.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Logo','','images/techyoucation grey.png',1)"><img src="images/full logo.png" alt="techyoucation logo" width="219" height="47" id="Logo" /></a></div>
<body>
<h1><br></h1>
	<div id="wrapper">
	<div id="menu">
		<a class="item" href="/forum/index.php">Home</a> -
		<a class="item" href="/forum/create_topic.php">Create a topic</a> -
		<a class="item" href="/forum/create_cat.php">Create a category</a>
		
		<div id="userbar">
		<?php
		if($_SESSION['signed_in'])
		{
			echo 'Hello <b>' . htmlentities($_SESSION['username']) . '</b>. Not you? <a class="item" href="signout.php">Sign out</a>';
		}
		else
		{
			echo '<a class="item" href="signin.php">Sign in</a> or <a class="item" href="signup.php">create an account</a>';
		}
		?>
		</div>
	</div>
		<div id="content">
 
Thanks in advance
 
Aled
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.