gabasc09 Posted August 20, 2009 Share Posted August 20, 2009 <?php $set_username = 'user'; $set_password = 'pass'; if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if(empty($username)){ $error['username'] = 1; } else { if($username == $set_username){ $error['username'] = 0; } else { $error['username'] = 2; } } if(empty($password)){ $error['password'] = 1; } else { if($password == $set_password){ $error['password'] = 0; } else { $error['password'] = 2; } } if($error['username'] == 0 && $error['password'] == 0){ session_start(); } } ?> <form method="post"> <table> <tr> <td>Username</td> <td><input type="text" name="username" value="<?php if($error['username'] == 0 && $error['password'] == 1 || $error['password'] == 2) {echo $username;} ?>" /></td> <td><?php if($error['username'] == 1){ echo 'Username is not entered';} elseif($error['username'] == 2) {echo 'Username is invalid';}?></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" /></td> <td><?php if($error['password'] == 1) { echo 'Password is not entered';} elseif($error['password'] == 2) { echo 'Password is invalid' ;} ?></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" /> </tr> </table> </form> I am unsure why im getting PHP notices. And may i ask if my method is conventional and good? If not please state why :\ Quote Link to comment Share on other sites More sharing options...
YourNameHere Posted August 24, 2009 Share Posted August 24, 2009 What are the notices? Topically, I see nothing wrong with the method. Quote Link to comment Share on other sites More sharing options...
gabasc09 Posted August 30, 2009 Author Share Posted August 30, 2009 Ok that was what killed me. I asked help from a few friends on MSN and they haven't seen notices like this. The notice given was that variables were not properly set. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.