freddyw Posted September 6, 2009 Share Posted September 6, 2009 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 https://forums.phpfreaks.com/topic/173322-tweaking-the-login-form/ Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 This is a question for JavaScript, not PHP. Link to comment https://forums.phpfreaks.com/topic/173322-tweaking-the-login-form/#findComment-913645 Share on other sites More sharing options...
freddyw Posted September 6, 2009 Author Share Posted September 6, 2009 really? i dont want to get cottered up in ajax. There must be a way to acchieve this php. Link to comment https://forums.phpfreaks.com/topic/173322-tweaking-the-login-form/#findComment-913652 Share on other sites More sharing options...
Batosi Posted September 6, 2009 Share Posted September 6, 2009 No once the page loads php will not do any more, you need to use ajax Link to comment https://forums.phpfreaks.com/topic/173322-tweaking-the-login-form/#findComment-913655 Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 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 https://forums.phpfreaks.com/topic/173322-tweaking-the-login-form/#findComment-913687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.