Current location: Hot Scripts Forums » Programming Languages » PHP » Hide the HTML form after user registered


Hide the HTML form after user registered

Reply
  #1 (permalink)  
Old 07-05-06, 08:45 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
Hide the HTML form after user registered

I have the following code:

PHP Code:

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


$problem FALSE;

  if (empty (
$_POST['username'])) {
  
$problem['username'] = TRUE;
  print 
"<p>Please enter a username !</p>\n";
  }

  if (
strlen($_POST['password']) < 8) {
  
$problem[''] = TRUE;
  print 
"<p>Please enter a password</p>\n"
  }

  if (
$_POST['password'] != $_POST['confirm']) {
  
$problem[''] = TRUE;
  print 
"<p>Please enter a password\n";
  } 


if (!
$problem) {
  print 
'Account added';
} else {
  print 
'Account not added';
}

}

<
form action="register.php" method="post">
Username:<br /><input type="text" name="username" size="30" maxlength="25"  /><br/> 
Password:<br /><input type="password" name="password" size="30" maxlength="15" /><br />
Confirma password:<br /><input type="password" name="confirm" size="30" maxlength="15" /><br />
<
p><input type="submit" name="submit" value="Register" /></p>
</
form>

</
body>
</
html
This code register a user.. But after "Account added" message I see the form again. After sucessfuly registration I want to hide the HTML form.

This code is not a solution for me because cut my last HTML codes, like </form>, </body> and </html> :

PHP Code:

if (!$problem) {

  print 
'Account added';
  exit();
} else {
  print 
'Account not added';
}

Any solution ? Any ideas?
Please help me if possible.

Thank you very much !
Reply With Quote
  #2 (permalink)  
Old 07-05-06, 02:36 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Here's one of many possible ways:
PHP Code:

<?php


if ( isset( $_POST['submit'] ) )
{
    
$problem FALSE;
    if ( empty( 
$_POST['username'] ) )
    {
        
$problem['username'] = TRUE;
        echo 
"<p>Please enter a username!</p>\n";
    }
    
/* etc... */
}

if ( 
$problem === FALSE )
    exit( 
header"Location: thankyou.php" ) );

/* ... registration form ... */

?>
__________________
The toxic ZCE
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
html form lguzman HTML/XHTML/XML 1 06-10-04 02:34 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
how do i re-fill the html form??? gaurav_sting PHP 1 12-21-03 12:13 PM


All times are GMT -5. The time now is 07:20 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.