Don't be offended, this code needs to be completely re-written with error reporting turned on.
I've put my comments in your code below.
Quote:
Originally Posted by hans_cellc
PHP Code:
<?PHP // Inialize session session_start(); // Import the connect to DB code as required as we need it and can not continue with out it. require 'connect_db.php';
?>
<!DOCTYPE html PUBLIC.. etc
<?PHP //PHP opening tag
<?PHP //What the? - Another one? - This code shouldn't work. // Inialize session session_start(); //You shouldn't be using this twice especially after html output has begun - This just shows you have error reporting turned off. // Import the connect to DB code as required as we need it and can not continue with out it. require 'connect_db.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Logging in - 48323934 - ICT 2613</title> <meta name="Description" content="PHP ICT2613 Exam Assignment. 48323934 - Logging in " /> <meta http-equiv="content-language" content="en-za" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="Author" content="S.J. Fouche, Student number: 48323934" /> <meta name="HandheldFriendly" content="True" /> <!-- Link to the external style sheet (CSS) --> <link rel="stylesheet" type="text/css" href="my_css.css" /> <!-- Link to the external javascript file --> <script type="text/javascript" src="my_javascript.js"></script>
</head>
<body> <!-- Used the include feature for the header and links on all pages --> <?PHP require "header.txt" ?>
<!-- Setup image --> <table width="640" height="350" align="center" cellpadding="0" cellspacing="1"> <tr align="center"><td><img src="site_graphics/controls.jpg" alt="Control Background" width="600" height="300" /></td></tr> </table>
<!-- PHP Coding --> <?PHP // Code below will create Code link at the center and bottom of the page echo("<p style='position:absolute; bottom:5px; left:49%;'><a href='javascript: logincode()'>Code</a></p>") ?>
</body> </html>
<?PHP
// username and password sent from form // My username and passwords are case sensitive and are not making use of: strtolower or strtoupper $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; echo $mypassword.'<br />'; // To protect MySQL injection $myusername = stripslashes($myusername); //Don't just use strip slashes $mypassword = stripslashes($mypassword); //Check for magic quotes first.
|
I've not checked the rest as it looks like you need to learn the basics about a few things first such as keeping php and html seperate
session_start() must be used before ANY output and should only be used once (ok you can use it more than once but only when you really know what you're doing and how it will work behind the scenes etc).
At one point you have TWO <?php opening tags