aeroblizz
02-22-2008, 08:12 AM
Hi
I got a script here provided by some1 else, everyone said it works, only here it doesn't show the HTML... it is an .php file so I can work with "echo" but it should be working like this aint it? or does any1 of you guys see an error in my script?
<?php
//always start the session before anything else!!!!!!
session_start();
if(isset($_POST['username'])&& $_POST['password']){
$username = $_POST['user_name']; //name of the text field for usernames
$password = $_POST['pass_word']; //likewise here just for the password
//connect to the db
$user = myusername;
$pswd = 'mypassword';
$db = mydb;
$conn = mysql_connect('localhost', $user, $pswd);
mysql_select_db($db, $conn);
//run the query to search for the username and password the match
$query = "SELECT * FROM users WHERE user_name = '$username' AND pass_word = '$password'";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
//this is where the actual verification happens
if(mysql_num_rows($result) == 1){
//the username and password match
//so e set the session to true
$_SESSION = true;
//and then move them to the index page or the page to which they need to go
header('Location: index.php');
}else{
$err = 'Incorrect username / password.' ;
}
//then just above your login form or where ever you want the error to be displayed you just put in
if isset($err) {
echo $err;
}
}
/**********THEN BELOW YOU WILL HAVE YOUR LOGIN FORM AND EVERYTHING ELSE*********/ ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MIJNTITE</title>
</head>
<body>
<form method="post" action="">
Username:<br>
<input type="text" name="username"><br>
Password:<br>
<input type="password" name="password"><br>
<input type="submit" name="login" value="Login">
</form>
</body>
</html>
My server has PHP5 running (btw when on my page, when I ceck the sourcecode with rightmouseclicking it shows an empty html :eek:
grtz
I got a script here provided by some1 else, everyone said it works, only here it doesn't show the HTML... it is an .php file so I can work with "echo" but it should be working like this aint it? or does any1 of you guys see an error in my script?
<?php
//always start the session before anything else!!!!!!
session_start();
if(isset($_POST['username'])&& $_POST['password']){
$username = $_POST['user_name']; //name of the text field for usernames
$password = $_POST['pass_word']; //likewise here just for the password
//connect to the db
$user = myusername;
$pswd = 'mypassword';
$db = mydb;
$conn = mysql_connect('localhost', $user, $pswd);
mysql_select_db($db, $conn);
//run the query to search for the username and password the match
$query = "SELECT * FROM users WHERE user_name = '$username' AND pass_word = '$password'";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
//this is where the actual verification happens
if(mysql_num_rows($result) == 1){
//the username and password match
//so e set the session to true
$_SESSION = true;
//and then move them to the index page or the page to which they need to go
header('Location: index.php');
}else{
$err = 'Incorrect username / password.' ;
}
//then just above your login form or where ever you want the error to be displayed you just put in
if isset($err) {
echo $err;
}
}
/**********THEN BELOW YOU WILL HAVE YOUR LOGIN FORM AND EVERYTHING ELSE*********/ ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MIJNTITE</title>
</head>
<body>
<form method="post" action="">
Username:<br>
<input type="text" name="username"><br>
Password:<br>
<input type="password" name="password"><br>
<input type="submit" name="login" value="Login">
</form>
</body>
</html>
My server has PHP5 running (btw when on my page, when I ceck the sourcecode with rightmouseclicking it shows an empty html :eek:
grtz