Jump to content

tweaking the login form.


freddyw

Recommended Posts

my login form works. I have no problem there. I just want it to look more professional. for instance if the user fills it in and has a password less than 6 characters, Id like it to say (in red), you password must be atlease 6 characters. and when the user choses an unavalable username id lile it to say. that username is taken please chose another. at the moment is says

 

Duplicate entry '(chosen username)' for key 1

 

my code

 


<html>
<Head>
<style type="text/css">

.hovermenu ul{
font: 16px arial;
padding-left: 0;
margin-left: 0;
height: 20px;
}

.hovermenu ul li{
list-style: none;
display: inline;
}

.hovermenu ul li a{
padding: 2px 0.5em;
text-decoration: none;
float: center;
color: black;
background-color: #FFF2BF;
border: 2px solid #FFF2BF;
}

.hovermenu ul li a:hover{
background-color: #FFE271;
border-style: outset;
}

html>body .hovermenu ul li a:active{ /* Apply mousedown effect only to NON IE browsers */
border-style: inset;
}

</style>
</head>

    </body>
        
            <div class="hovermenu">
                <center>
                <ul>
                    <li><a href="http://fredundant.byethost11.com/">Home</a></li>
                    <li><a href="http://fredundant.byethost11.com/register.php">Register</a></li>
                    <li><a href="http://fredundant.byethost11.com/log.php">Members Area</a></li>
                    <li><a href="">Nothing Here Yet</a></li>
                    <li><a href="">Nothing Here Yet</a></li>
                </ul>
                </center>
            </div>
      
    </body>





<?php
  //include("header.php");

  //can we use mysql?
  if(!function_exists('mysql_connect')) die("MySQL extension not enabled");

  //connect to mysql server
  connecction details removed

  //find our script name
  $script = $_SERVER['PHP_SELF'];
?>
<h1>
<FONT FACE="Arial, Helvetica, Geneva"> 


<center>
user registration
</center>
</FONT>
</h1>
<?php
  //are we being posted to?
  if($_SERVER['REQUEST_METHOD'] == "POST"){
    //yes! set our variables
    
    $first_name = (isset($_POST['first_name'])) ? mysql_real_escape_string($_POST['first_name']) : '';
    $last_name = (isset($_POST['last_name'])) ? mysql_real_escape_string($_POST['last_name']) : '';
    $email = (isset($_POST['email'])) ? mysql_real_escape_string($_POST['email']) : '';
    $username = (isset($_POST['username'])) ? mysql_real_escape_string($_POST['username']) : '';
    $password = (isset($_POST['password'])) ? mysql_real_escape_string($_POST['password']) : '';
    $verify = (isset($_POST['verify'])) ? mysql_real_escape_string($_POST['verify']) : '';
    

    //verify password start
    
     if($password != $verify) {
     die ('Sorry, The passwords you entered didn\'t match<br>Please use your browsers back button to try again');
     }
    
    //verify password ends
    
    if($username != '' && $password != ''){
      //database stuff: insert a new user
      
      
      if (strlen($password) < 6) {
   $error = "Your password must be at least 6 characters long.";
   }
      
      
      $sql = "INSERT INTO user (first_name, last_name, email, username, password) VALUES('$first_name', '$last_name', '$email', '$username', '$password')";
      mysql_query($sql) or die(mysql_error());
?>
<h3>
<FONT FACE="Arial, Helvetica, Geneva">
thanks for registering.
</FONT>
</h3>
<?php
    }else{
      //they didn't fill something in
      $error = true;
    }
  }
  if(isset($error) || $_SERVER['REQUEST_METHOD'] != "POST"){
    //show the form

?>
<h4><center><FONT FACE="Arial, Helvetica, Geneva"> choose your desired username and password below</FONT></center></h4>
<?php if(isset($error)){ ?>
<span style="color: #f00;">there was an error. please make sure you enter information into all fields correctly.<br> Your password must be a minimum of 6 characters.</span>
<?php } ?>




<table width='100%' height='100%'>
<form method="post" action="<?php echo $script; ?>">
<tr><td align=center>
    <table>
    <tr><td>
    <table>
    <tr><td>
  fisrt name:</td><td><input type="text" name="first_name" />
  </td></tr>
    <tr><td>last name:</td><td><input type="text" name="last_name" />
  </td></tr>
    <tr><td>email address:</td><td><input type="text" name="email" />
  </td></tr>
    <tr><td>username:</td><td> <input type="text" name="username" />
  </td></tr>
    <tr><td>password:</td><td>  <input type="password" name="password" />
</td></tr>
    <tr><td> verify password:</td><td><input type="password" name="verify" />
   </table>
    </td></tr>
    <tr><td align=center>
  <input type="submit" value="Register" />
</table>
    </td></tr>
    </form>
    </table>


<?php } ?> 


</body>
</html>

Link to comment
Share on other sites

really?

 

i dont want to get cottered up in ajax.

 

There must be a way to acchieve this php.

 

AJAX and JavaScript are quite different (AJAX employs JavaScript to call pages such as PHP to do things), but JavaScript itself is inherently client-sided. It does not require AJAX to run.

 

Again, refer to the javascript forum for this question.

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.