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
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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"];

 

}?>

Link to comment
Share on other sites

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"];
}
}

Link to comment
Share on other sites

<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>';

?>

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.