sudsy1970 Posted November 25, 2008 Share Posted November 25, 2008 hi all, just a couple of quick questions hopefully shouldn't be too difficult for you. 1) Have already got a script in place to search database if you forget your password, you enter the username and it searches details and then emails the password to the registered address. If i wanted to add a forgot username facility, could i modify my existing account to say something like SELECT * from 'db' WHERE username=$_POST[posted username} OR WHERE firstname AND surname=$_POST[posted firstname],$_POST[surname]; or would i need to just create a seperate file for this? 2) Updates. If i include a form to update members details say, firstname, surname, email address etc, and only the email address was filled in, if i updated all would this then wipe the data that was in the database for the other info or would it just update the email address as that is the only field in the form that has been filled in? Cheers for any insight Sudsy Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/ Share on other sites More sharing options...
waynew Posted November 25, 2008 Share Posted November 25, 2008 2) Updates. If i include a form to update members details say, firstname, surname, email address etc, and only the email address was filled in, if i updated all would this then wipe the data that was in the database for the other info or would it just update the email address as that is the only field in the form that has been filled in? Well, the best thing to do here is to output the users data to form fields and then update every column with those field values. Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698469 Share on other sites More sharing options...
waynew Posted November 25, 2008 Share Posted November 25, 2008 To allow him or her to get their username, you had better ask them to give you something that is unique, such as an email address... $result = mysql_query("SELECT username, email from 'db' WHERE email = '$email_address'") or die(mysql_error()); $r = mysql_fetch_row($result); if(mysql_num_rows($result) > 0){ $email_message = 'Your username is '.$r[1]; //Then send email - or something like that } Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698470 Share on other sites More sharing options...
sudsy1970 Posted November 25, 2008 Author Share Posted November 25, 2008 Thanks for the replys. Got the second one but not really sure what you mean with the updates. Do you mean retrieve members details and then try to populate them into the update form ? then resubmit to the database ? if so i could get the details and then resubmit no probs but as to how to populate the form ???? Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698476 Share on other sites More sharing options...
waynew Posted November 25, 2008 Share Posted November 25, 2008 <input name="username" type="text" value="<?php echo htmlentities($username); ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698489 Share on other sites More sharing options...
sudsy1970 Posted November 25, 2008 Author Share Posted November 25, 2008 Ok i take it then i would have to assign the details first befor using the code. i.e $username=$dbReocord["username"]; Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698512 Share on other sites More sharing options...
waynew Posted November 25, 2008 Share Posted November 25, 2008 Or you could do it like so: <input name="username" type="text" value="<?php echo htmlentities($dbRecrord["username"]); ?>" /> As long as the variable you're outputting contains that username, it'll be ok. Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698513 Share on other sites More sharing options...
sudsy1970 Posted November 25, 2008 Author Share Posted November 25, 2008 brilliant thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/134177-solved-couple-of-mysql-questions/#findComment-698518 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.