Php error

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Php error

Postby arjita » 26. July 2007 17:05

Attached below is my code for a php script (it has no database look up required)..I can't get what I need to print.Also how can I encrypt the password.Any help would be appreciated ..Thanks


Code: Select all
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
$username = $_POST['username'];
$password = $_POST['password'];

if (($username == "Arjita") && (password == "sameer")){

print("Welcome Arjita");
}
else
{
   print("you are not authorized to vie this ");
}

?>
</head>

<body>
<p>
  <input name="username" type="text" />
</p>

  <input name="password" type="text" />

<p>&nbsp;</p>
<p>
  <input type = "Submit" name = "Submit1" value = "Login" />
</p>

<Form name ="form1" Method ="POST" Action ="C:\xampp\htdocs\Login.php">
</FORM>
</body>
</html>
arjita
 
Posts: 6
Joined: 17. July 2007 20:35

Postby glitzi85 » 26. July 2007 17:24

Hello,

try out this:

Code: Select all
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if(($_POST['username'] == 'Arjita') && (md5($_POST['password']) == 'd524813536b71639999ba12bdb3621a8')){
 echo "Welcome Arjita";
}else{
 echo "You are not authorized to view this");
}
?>
<form action="./Login.php" method="post">
  Username: <input type="text" name="username">
  Password: <input type="password" name="password">
  <input type="submit" value="Login">
</form>
</body>
</html>


Normally you would not give out the formular any more if login is suceed, but for your test this is not neccessary.

For further Information please also refer to the PHP-Manual located here: http://www.php.net/manual/en/

To prevent your potentially next question: Save the File in C:\xampp\htdocs\ as Login.php (exactly in this notation!). Then open your Browser and load http://localhost/Login.php Your Site should be loaded (if you startet the Apache Webserver).

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 66 guests