SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    Code PHP:
    <?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

  2. #2
    SitePoint Member
    Join Date
    Nov 2009
    Location
    Wisconsin
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your condition
    PHP Code:
    echo $formValues['name']; 
    Is not in the form.

    That little part in your condition should be
    PHP Code:
    echo $formValues['username']; 
    It's very easy to overlook these little typo mistakes....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •