searls03 Posted July 27, 2011 Share Posted July 27, 2011 ok, so I have this so far and I want it to echo password does not match if password123 does not equal password. and if it does match the sql query will run. do i put the else statement after the sql or before it. could you tell me where to start it........like put a comment that shows where? <?php // Process the form if it is submitted $password1 = $_POST['password']; $password123 = md5($password1); if ($_POST['passbut']) { if ($password123 == $password) { $password12 = $_POST['password']; $sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error()); $message ='Your Account info has been saved'; echo "<font color = 'red'>"; echo $message; echo "</font>"; }} // close if post ?> Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/ Share on other sites More sharing options...
AyKay47 Posted July 27, 2011 Share Posted July 27, 2011 <?php // Process the form if it is submitted $password1 = $_POST['password']; $password123 = md5($password1); if (isset($_POST['passbut'])) { if ($password123 == $password) { //im assuming that $password is coming from your db $password12 = $_POST['password']; $sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error()); $message ='Your Account info has been saved'; echo "<font color = 'red'>"; echo $message; echo "</font>"; }else{ //passwords do not match } } // close if post ?> Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248002 Share on other sites More sharing options...
searls03 Posted July 27, 2011 Author Share Posted July 27, 2011 other piece that I want to do is also make sure that the new and confirm passwords match. how do I do that? <?php // Process the form if it is submitted $password1 = $_POST['password']; $password2 = $_POST['new']; $password3 = $_POST['password']; $password123 = md5($password1); if (isset($_POST['passbut'])) { if ($password123 == $password) { $password12 = $_POST['password']; $sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error()); $message ='Your Account info has been saved'; echo "<font color = 'red'>"; echo $message; echo "</font>"; }else{ echo '<font color="red">'; echo "passwords do not match"; echo '</font>'; } } // close if post ?> <hr /> <font size="2px" color="#666666">Your Password</font><br /> <br /> <br /> <br /> <br /> </div> <div class="CollapsiblePanelContent"><form action="settings.php" method="post"><table width="371" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="109" height="29" scope="col">Old Password:</td> <td width="242" scope="col"><label for="password"></label> <div align="left"> <input name="password" type="text" id="password" /> </div></td> </tr> <tr> <td>New Password:</td> <td><label for="new"></label> <div align="left"> <input type="text" name="new" id="new" /> </div> <label for="security"></label></td> </tr> <tr> <td>Confirm Password:</td> <td><label for="confirm"></label> <div align="left"> <input type="text" name="confirm" id="confirm" /> </div> <label for="answer"></label></td> </tr></table><input name="passbut" type="submit" class="fullname" value="Save Password" id="passbut"/> <br /> <br /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248091 Share on other sites More sharing options...
searls03 Posted July 29, 2011 Author Share Posted July 29, 2011 did that part make sense? could you put a comment where I should put it? did I also do the other part right? Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248810 Share on other sites More sharing options...
AyKay47 Posted July 29, 2011 Share Posted July 29, 2011 not really, new and confirm passwords? why would they match Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248816 Share on other sites More sharing options...
searls03 Posted July 29, 2011 Author Share Posted July 29, 2011 when you verify that the new password was typed in the new and confirm, to make sure they match. so that the person can be make sure that the password they wanted is what they have. Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248817 Share on other sites More sharing options...
Pikachu2000 Posted July 29, 2011 Share Posted July 29, 2011 Your code has a logical problem. Why would you assign the same value to both $password1 and $password3? If anything, shouldn't you be assigning $_POST['confirm'] to one of those, after comparing the values of $_POST['new'] and $_POST['confirm']? Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248823 Share on other sites More sharing options...
searls03 Posted July 29, 2011 Author Share Posted July 29, 2011 this is why I am asking a question. I have never tried a password thing like this. could you help? Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248825 Share on other sites More sharing options...
AyKay47 Posted July 29, 2011 Share Posted July 29, 2011 where is $password coming from, you dont initialize it in your code prior to comparing it to $password123 Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248827 Share on other sites More sharing options...
searls03 Posted July 29, 2011 Author Share Posted July 29, 2011 it is earlier in code that I didn't post, it is what is directly coming from database. Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248828 Share on other sites More sharing options...
Ninjakreborn Posted July 29, 2011 Share Posted July 29, 2011 Please post ALL of your code, and be specific about what you are trying to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248865 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.