Code: Select all
<script type="text/javascript" src="md5.js"></script>Moderator: General Moderators
Code: Select all
<script type="text/javascript" src="md5.js"></script>Code: Select all
hashedpassword =hex_md5(document.getElementById('password').value)Code: Select all
<script type="text/javascript" src="md5.js"></script>Code: Select all
<?
session_start();
include 'maintfunctions.php';
if($_POST['username']=="")
{
?>
<script type="text/javascript" src="md5.js"></script>
<SCRIPT LANGUAGE ="javascript">
alert("Sorry the Username is incorrect please try again.");
document.write('<? UserLogin(); ?>');
</SCRIPT>
<?
}
else
{
$username = $_POST['username'];
$link = odbc_connect("ImmagetechQuiz","Trainee","tra1ning");
$passwordquery = "SELECT Password FROM tblStudents WHERE Username ='$username'";
$presult = odbc_exec($link,$passwordquery);
if(odbc_fetch_row($presult))
{
$_SESSION['password'] = md5(odbc_result($presult,"Password"))+$_SESSION['challange'];
?>
<SCRIPT LANGUAGE ="text/javascript">
hashedpassword ="";
if(document.getElementById.value =="")
{
alert("Please enter your password.");
document.write('<?UserLogin();?>');
}
else
{
hashedpassword = hex_md5(document.getElementById('password').value);
hasheedpassword = hashedpassword+'<? echo $_SESSION['challange']?>';
}
if(hashedpassword ==<? echo $_SESSION['password']?>)
{
window.location('http://localhost/MainMenu.php');
}
else
{
alert("Your username or password was incorrect please try again.");
document.write('<?UserLogin();?>');
}
</SCRIPT>
<?
}
else
{
?>
<SCRIPT LANGUAGE = "javascript">
alert("Username does not exist in Database please try again.");
document.write('<?UserLogin();?>');
</SCRIPT>
<?
}
}
?>If that is the page in its entirety the problem is that its not an html page at all! You don't have:nawhaley wrote:the page isnt actually live yet I'm doing testing and debugging on my local PC using Apache to debug the PhP code and firefoxs javascript console for the javascript debugging. Here is the page in its entirety hopefully this will help.
Code: Select all
<html>
<head>
<!-- // Javascript should go in here, ideally! -->
</head>
<body>
</body>
</html>PHP is the processing language. The *output*, which you want a browser to interpret, is text.nawhaley wrote:all the pages I'm doing are at heart PhP pages
If it is not HTML, there is no "predictable" behavior at all. The browsers behavior is undefined. Thats why you produce compliant HTML code - so that you get a predictable behavior, and can debug whats going wrong.nawhaley wrote:thats one of the reasons I didnt bother with the HTMl header tags etc. All my other pages are designed similarly with inline javascript and act predictably save this one.
It will change the situation. Currently, you give an undefined set of text to a browser and hope it does what you think it should.nawhaley wrote:I'll add those lines to it then do my PHP if you feel it will make a difference to the way the scripts reacting.
Code: Select all
<HTML>
<HEAD>
<SCRIPT type="text/javascript" src="md5.js">
function password()
{
hashedpassword ="";
if(document.getElementById('password').value =="")
{
alert("Please enter your password.");
document.write('<?UserLogin();?>');
}
else
{
hashedpassword = hex_md5(document.getElementById('password').value);
hasheedpassword = hashedpassword+'<? echo $_SESSION['challange']?>';
}
if(hashedpassword ==<? echo $_SESSION['password']?>)
{
window.location('http://localhost/MainMenu.php');
}
else
{
alert("Your username or password was incorrect please try again.");
document.write('<?UserLogin();?>');
}
}
</SCRIPT>
</HEAD>
<BODY>
<?
session_start();
include 'maintfunctions.php';
if($_POST['username']=="")
{
?>
<SCRIPT LANGUAGE ="javascript">
alert("Sorry the Username is incorrect please try again.");
document.write('<? UserLogin(); ?>');
</SCRIPT>
<?
}
else
{
$username = $_POST['username'];
$link = odbc_connect("ImmagetechQuiz","Trainee","tra1ning");
$passwordquery = "SELECT Password FROM tblStudents WHERE Username ='$username'";
$presult = odbc_exec($link,$passwordquery);
if(odbc_fetch_row($presult))
{
$_SESSION['password'] = md5(odbc_result($presult,"Password")+$_SESSION['challange']);
}
else
{
?>
<SCRIPT LANGUAGE = "javascript">
alert("Username does not exist in Database please try again.");
document.write('<?UserLogin();?>');
</SCRIPT>
<?
}
}
?>
</BODY>
</HTML>Ok in response to this and my following confusion on how to make it a "webpage" are there any sites that show the "proper" way to do PhP so its not as you put it "tag soup". Because out of all the sites I've seen my code really isnt any worse than anyone elses and 99% of it is working. I'm all for making clean and compliant code so long as I have rules and a model to go by. The issue with doing that currently is I had no rules no guidelines and no help when I started this. I simply picked up PHP because my buisness needed a project done and told me to do it. I "am" the IT department here so anything that gets done gets done by me including code which means I have no referances no one to ask if my code is compliant or not which is why you get the jumbled mess of code you see above me.Roja wrote:If that is the page in its entirety the problem is that its not an html page at all! You don't have:nawhaley wrote:the page isnt actually live yet I'm doing testing and debugging on my local PC using Apache to debug the PhP code and firefoxs javascript console for the javascript debugging. Here is the page in its entirety hopefully this will help.
Without those items (and actually, you need a few more), its not even a webpage you are producing, so there is no reasonable way to guess what a webbrowser will do with it.Code: Select all
<html> <head> <!-- // Javascript should go in here, ideally! --> </head> <body> </body> </html>