Page refresh, get post values

Hi

I am writing a login script for my site, I want a user to be able to login in on th index page and return to the index page on submit and process the values from a username and password box, I’m having a little trouble with getting this to work, this is my code.


<?php

session_start();

function vaildateUser(&$value)
{

}

function displayForm($values)
{


	echo '<html>';
	echo '<head>';
	echo '<title> MY SITE TITLE </tile>';
	echo '</head>';
		
	echo '<body>';
		
	echo "<form action=\\"{$_SERVER['PHP_SELF']}\\" method=\\"POST\\">";
	echo "<input name=\\"username\\" id=\\"username\\" type=\\"text\\" size=\\"20\\" value=\\"{$values['name']}\\" />";
	echo '<input name=\\"password\\" id=\\"password\\" type=\\"password\\" size=\\"20\\" />';
	echo '<input type=submit name=\\"Submit\\" value="Login">';
	echo '</form>';
	echo '</body>';
	echo '</html>';
	

}

	if ($_SERVER['REQUEST_METHOD'] == 'POST')
	{
		$formValues = $_POST;
		
		displayForm($formValues);
		echo $formValues['name'];
		
	}
	else
	{
		displayForm(null);
	}
?>

Thanks for any help.

James

In your condition

echo $formValues['name'];

Is not in the form.

That little part in your condition should be

echo $formValues['username'];

It’s very easy to overlook these little typo mistakes…