Hi everyone,
I am a newbie in web design, i am stuck at this login script.
In my main page, i have this code as my login:
Code:
<form action="cp.php" method="post">
<img src="../../../../Desktop/for web/for web here/login.png" width="170" height="60" /> Username:
<label>
<input name="username" value="" type="text" />
</label>
<label>Password:
<input name="password" value="" type="password" />
</label>
<p>
<input name="login" value="Sign In" type="submit" id="login" />
</p>
</form>
As you see it will go to my cp.php, in cp.php i have attached mysql dc infomation:
Code:
<?php
//Include the required file
if(file_exists('config.php')){
require_once("config.php");
$session->stop();
}
//The Ajax function
echo " <script language=\"javascript\" type=\"text/javascript\">
<!--
function ajaxFunction(url, div, menu, addon){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
try{
ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\");
} catch (e){
alert(\"Your browser broke!\");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var divc = document.getElementById(div);
var result = ajaxRequest.responseText;
divc.innerHTML = result;
if(!result){
ajaxFunction(\"main.php\", \"content\", 1);
} else if(result == 'error'){
ajaxFunction(\"error.php\", \"content\", 2);
}
if(menu == 2){
var divc = document.getElementById('menu');
divc.innerHTML = '';
} else if(menu){
ajaxFunction(\"menu.php\", \"menu\", 0);
}
}
}
url=encodeURIComponent(url);
if(!addon){
addon = '';
}
ajaxRequest.open(\"GET\", \"$cp_content_folder/\" + url + addon, true);
ajaxRequest.send(null);
}
function form_submit(url, form){
var addon = ''
for(i=0; i < form.elements.length; i++){
addon += form.elements[i].name + '=' + form.elements[i].value.replace(/\\n/g,'<br />') + '&';
}
ajaxFunction(url, 'content', 0, '?' + addon);
}
onerror=CallError;
var txt = \"\";
function CallError(msg,url,line){
txt=\"Error: \"+msg+\"\\n\";
txt=txt+\"URL: \"+url+\"\\n\";
txt=txt+\"Line: \"+line+\"\\n\\n\";
alert(txt);
return true;
}";
if($cp_nav != ""){
echo "ajaxFunction('" . $cp_nav . ".php', 'content', 1";
if($cp_sub != "") echo ", '?sub=" . $cp_sub . "'";
echo ");";
} else echo "ajaxFunction('logged.php', 'content', 1);";
echo "
//-->
</script>";
?>
and now to the logged.php, at the top of logged.php i put this:
Code:
<?php
session_start();
if (!isset($_SESSION['user']))
{
die ("Access Denied");
}
?>
WHEN I CLICK ON THE main page I dont have to type any username or password i just clicked login and it linked me to cp.php and appear only this code :
Code:
stop(); } //The Ajax function echo " "; ?>
Anyone know what's happening?

Your answer is appreciated.