[HTML / CSS / PHP?] Disappearing Text

Newbie Spellweaver
Joined
Apr 13, 2008
Messages
91
Reaction score
1
You know how on Facebook when you click the email box the text 'email' disappears? Do you know how I could do something similar to that?

Thanks in advance,
Matty
 
Any chance you could post a picture and explain it better, not everyone uses facebook.
Okay, so. On Facebook, when you're about to log in. There are the login boxes. In the box it says "Email" and "Password" in another in a dull gray color. Then, when you click the box, the text disappears.
 
Just add the onFocus state to the registration form, simple as that.
Code:
onFocus="this.value=''"
Oh, thanks again.

Edit -
Code:
Parse error: parse error, expecting `','' or `';'' in C:\xampp\htdocs\OdinLite\register.php on line 21
PHP error. >_>;
 
Paste your form here.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="popstyle.css" type="text/css" media="screen" /></head>

<body class="oneColElsCtr">
<div id="container">
  <div id="mainContent">
<?php
require('config.php');
    if(!$_POST['register']){
        echo "<form method=\"POST\">";
        echo "<center><table border=\"0\" width=\"200\">";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Username</b></td><td><input type=\"text\" 

name=\"username\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Password</b></td><td><input type=\"password\" 

name=\"password\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Confirm Password</b></td><td><input type=\"password\" 

name=\"cpassword\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>E-Mail</b></td><td><input type=\"text\" 

name=\"email\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Birthday</b><br /><i>(YYYY-MM-DD)</i></td><td 

valign=\"top\"><input type=\"text\" maxlength=\"10\" name=\"birth\"></td></tr>";
        echo "<tr><td></td><td><input type=\"submit\" value=\"Register\" name=\"register\">";
        echo "</table></center></form>";
    }else{
        $username = mysql_real_escape_string($_POST['username']);
        $password = mysql_real_escape_string($_POST['password']);
        $cpassword = mysql_real_escape_string($_POST['cpassword']);
        $email = mysql_real_escape_string($_POST['email']);
        $birth = mysql_real_escape_string($_POST['birth']);
        
        $ucheck = mysql_query("SELECT * FROM `accounts` WHERE `name`='".$username."'") or die(mysql_error());
        if($username == ""){
            echo "Please supply an username!";
        }elseif(mysql_num_rows($ucheck) >= 1){
            echo "The username already exists. Please select another one!";
        }elseif($password == ""){
            echo "Please supply a password!";
        }elseif($password != $cpassword){
            echo "The passwords don't match!";
        }elseif($email == ""){
            echo "Please supply an e-mail!";
        }elseif(strlen($username) < 4){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($username) > 12){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($password) < 6){
            echo "Password must be between 6 and 12 characters!";
        }elseif(strlen($password) > 12){
            echo "Password must be between 6 and 12 characters!";
        }elseif($birth == ""){
            echo "Please supply a birth date!";
        }else{
            $ia = mysql_query("INSERT INTO `accounts` (`name`,`password`,`birthday`,`email`) VALUES 

('".$username."','".sha1($password)."','".$birth."','".$email."')") or die(mysql_error());
            echo "The user has been succesfully added into the database! You can now log into the community 

and in-game!<br /><br />";
            echo "blahblah<br />";
            echo "BLAHBLAH";
        }
    }
?>
  </p>
    <!-- end #mainContent --></div>
<!-- end #container --><img src="img/copyrightsm.gif" /></div>
</body>
</html>
 
Try
Code:
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="popstyle.css" type="text/css" media="screen" /></head>

<body class="oneColElsCtr">
<div id="container">
  <div id="mainContent">
<?php
require('config.php');
    if(!$_POST['register']){
        echo "<form method=\"POST\">";
        echo "<center><table border=\"0\" width=\"200\">";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Username</b></td><td><input type=\"text\" 

name=\"username\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Password</b></td><td><input type=\"password\" 

name=\"password\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Confirm Password</b></td><td><input type=\"password\" 

name=\"cpassword\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>E-Mail</b></td><td><input type=\"text\" 

name=\"email\" value=\"Enter your email\" onFocus=\"this.value=''\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Birthday</b><br /><i>(YYYY-MM-DD)</i></td><td 

valign=\"top\"><input type=\"text\" maxlength=\"10\" name=\"birth\"></td></tr>";
        echo "<tr><td></td><td><input type=\"submit\" value=\"Register\" name=\"register\">";
        echo "</table></center></form>";
    }else{
        $username = mysql_real_escape_string($_POST['username']);
        $password = mysql_real_escape_string($_POST['password']);
        $cpassword = mysql_real_escape_string($_POST['cpassword']);
        $email = mysql_real_escape_string($_POST['email']);
        $birth = mysql_real_escape_string($_POST['birth']);
        
        $ucheck = mysql_query("SELECT * FROM `accounts` WHERE `name`='".$username."'") or die(mysql_error());
        if($username == ""){
            echo "Please supply an username!";
        }elseif(mysql_num_rows($ucheck) >= 1){
            echo "The username already exists. Please select another one!";
        }elseif($password == ""){
            echo "Please supply a password!";
        }elseif($password != $cpassword){
            echo "The passwords don't match!";
        }elseif($email == ""){
            echo "Please supply an e-mail!";
        }elseif(strlen($username) < 4){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($username) > 12){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($password) < 6){
            echo "Password must be between 6 and 12 characters!";
        }elseif(strlen($password) > 12){
            echo "Password must be between 6 and 12 characters!";
        }elseif($birth == ""){
            echo "Please supply a birth date!";
        }else{
            $ia = mysql_query("INSERT INTO `accounts` (`name`,`password`,`birthday`,`email`) VALUES 

('".$username."','".sha1($password)."','".$birth."','".$email."')") or die(mysql_error());
            echo "The user has been succesfully added into the database! You can now log into the community 

and in-game!<br /><br />";
            echo "blahblah<br />";
            echo "BLAHBLAH";
        }
    }
?>
  </p>
    <!-- end #mainContent --></div>
<!-- end #container --><img src="img/copyrightsm.gif" /></div>
</body>
</html>
 
Try
Code:
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="popstyle.css" type="text/css" media="screen" /></head>

<body class="oneColElsCtr">
<div id="container">
  <div id="mainContent">
<?php
require('config.php');
    if(!$_POST['register']){
        echo "<form method=\"POST\">";
        echo "<center><table border=\"0\" width=\"200\">";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Username</b></td><td><input type=\"text\" 

name=\"username\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Password</b></td><td><input type=\"password\" 

name=\"password\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Confirm Password</b></td><td><input type=\"password\" 

name=\"cpassword\" maxlength=\"12\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>E-Mail</b></td><td><input type=\"text\" 

name=\"email\" value=\"Enter your email\" onFocus=\"this.value=''\"></td></tr>";
        echo "<tr><td align=\"right\" width=\"50%\"><b>Birthday</b><br /><i>(YYYY-MM-DD)</i></td><td 

valign=\"top\"><input type=\"text\" maxlength=\"10\" name=\"birth\"></td></tr>";
        echo "<tr><td></td><td><input type=\"submit\" value=\"Register\" name=\"register\">";
        echo "</table></center></form>";
    }else{
        $username = mysql_real_escape_string($_POST['username']);
        $password = mysql_real_escape_string($_POST['password']);
        $cpassword = mysql_real_escape_string($_POST['cpassword']);
        $email = mysql_real_escape_string($_POST['email']);
        $birth = mysql_real_escape_string($_POST['birth']);
        
        $ucheck = mysql_query("SELECT * FROM `accounts` WHERE `name`='".$username."'") or die(mysql_error());
        if($username == ""){
            echo "Please supply an username!";
        }elseif(mysql_num_rows($ucheck) >= 1){
            echo "The username already exists. Please select another one!";
        }elseif($password == ""){
            echo "Please supply a password!";
        }elseif($password != $cpassword){
            echo "The passwords don't match!";
        }elseif($email == ""){
            echo "Please supply an e-mail!";
        }elseif(strlen($username) < 4){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($username) > 12){
            echo "Username must be between 4 and 12 characters!";
        }elseif(strlen($password) < 6){
            echo "Password must be between 6 and 12 characters!";
        }elseif(strlen($password) > 12){
            echo "Password must be between 6 and 12 characters!";
        }elseif($birth == ""){
            echo "Please supply a birth date!";
        }else{
            $ia = mysql_query("INSERT INTO `accounts` (`name`,`password`,`birthday`,`email`) VALUES 

('".$username."','".sha1($password)."','".$birth."','".$email."')") or die(mysql_error());
            echo "The user has been succesfully added into the database! You can now log into the community 

and in-game!<br /><br />";
            echo "blahblah<br />";
            echo "BLAHBLAH";
        }
    }
?>
  </p>
    <!-- end #mainContent --></div>
<!-- end #container --><img src="img/copyrightsm.gif" /></div>
</body>
</html>
Email does! I'll learn from it. Thanks!

Edit -
The only thing is that when I do it for password it comes out as the dots.
 
Back