Jump to content

I need help with a very simple code


italiano40

Recommended Posts

<html>
<head>
<title>Welcome please login</title>
</head>
<body>
<body bgcolor="#ff3333">
<form action="login.php" method="post">
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="password" name="password" /></p>
<p><input type="submit"/><input type="reset" /></p>
<p><a href="createaccount.htm">Create an Account</a></c></p>
</form>
</body>
</html>

<?php
if($_POST["username"]=="italiano40" && $_POST["password"]=="mafia2")
echo $_REQUEST["username"];
else
echo $_REQUEST["password"];
?>

how come it will not print the password and username, i just

get a blank page

Link to comment
https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/
Share on other sites

try this

<?

if(isset($_POST['login'])){

if($_POST["username"]=="abc" && $_POST["password"]=="abc")

echo $_REQUEST["username"];

else

echo $_REQUEST["password"];

 

}

 

?>

<html>

<head>

<title>Welcome please login</title>

</head>

<body>

<body bgcolor="#ff3333">

<form action="<?=$_SERVER[php_SELF]?>" method="post">

<p>Username: <input type="text" name="username" /></p>

<p>Password: <input type="password" name="password" /></p>

<p><input type="submit" name="login" value="LOGIN"/>

<input type="reset" /></p>

<p><a href="createaccount.htm">Create an Account</a></c></p>

</form>

</body>

</html>

still doesn't work

but it is 2 different files

 

one is html

and one is PHP

 

and it works because if i ask it to redirect to other webpages it works

but when it tries to print to the screen it doesn't work

 

is their anything else i can do

expect print because that doesn't work either.

html

<html>

<head>

<title>Welcome please login</title>

</head>

<body>

<body bgcolor="#ff3333">

<form action="login.php" method="post">

<p>Username: <input type="text" name="username" /></p>

<p>Password: <input type="password" name="password" /></p>

<p><input type="submit" name="login" value="LOGIN"/>

<input type="reset" /></p>

<p><a href="createaccount.htm">Create an Account</a></c></p>

</form>

</body>

</html>

login.php

<?

 

if(isset($_POST['login'])){

if($_POST["username"]=="abc" && $_POST["password"]=="abc")

echo $_REQUEST["username"];

else

echo $_REQUEST["password"];

 

}?>

try it with user name abc and password abc than it will show you the user name and pass.

 

Or if not working then try to change to this:

if(isset($_POST['login'])){
   if($_POST["username"]=="abc" && $_POST["password"]=="abc"){
echo $_POST["username"];
else
echo $_POST["password"];
}
}

<html>

<head>

<title>Welcome please login</title>

</head>

<body>

<body bgcolor="#ff3333">

<form action="login.php" method="post">

<p>Username: <input type="text" name="username" /></p>

<p>Password: <input type="password" name="password" /></p>

<p><input type="submit" name="login" value="LOGIN"/>

<input type="reset" /></p>

<p><a href="createaccount.htm">Create an Account</a></c></p>

</form>

</body>

</html>

 

When you enter abc as username and abc as password it will redirect to login.php

NOW ..

Try to echo the post value simply using

login.php

<?

echo'<pre>';

print_r($_POST);

echo'</pre>';

?>

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.