scm22ri Posted August 8, 2012 Share Posted August 8, 2012 How does one pass or get information into a mysql database without having the user type something into a input field? In other words, can the fields be auto-populated with information the user can't edit/change? If so, how can that be done? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/ Share on other sites More sharing options...
Psycho Posted August 8, 2012 Share Posted August 8, 2012 Hmm, you can set any values YOU wish. You can have the user submit a form and then completely overwrite any data they may or may not have entered with hard coded data. I'm not really sure what you are asking. $favoriteSnack = $_POST['user_submitted_favorite_snack']; if($favoriteSnack != 'Ding Dongs') { //Ding dongs rule all bitches ! ! ! $favoriteSnack = 'Ding Dongs'; } $query = "UPDATE USERS SET favorite_snack = '$favoriteSnack' WHERE user_id = $user_id"; Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367698 Share on other sites More sharing options...
requinix Posted August 8, 2012 Share Posted August 8, 2012 The user can do whatever he wants - what matters is what you do. Don't want them to edit a name or number? Then make sure your code never tries to do that. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367713 Share on other sites More sharing options...
peipst9lker Posted August 8, 2012 Share Posted August 8, 2012 Keep in mind any user can modify POST and GET data easily. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367725 Share on other sites More sharing options...
requinix Posted August 8, 2012 Share Posted August 8, 2012 And cookies! Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367726 Share on other sites More sharing options...
scm22ri Posted August 8, 2012 Author Share Posted August 8, 2012 This is what I mean, instead of having a user submit information I want the information to already be pre-populated. In the below URL example, for the make and model I want it to read Ford, Explorer. (It currently does) but how would I pass the value of "Ford" and "Explorer" into my mysql database? http://whatsmyowncarworth.com/auto-practice/submit-information2.php Thanks Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367759 Share on other sites More sharing options...
thomasw_lrd Posted August 8, 2012 Share Posted August 8, 2012 If it's always going to be the same, you can just hard code it into your insert statement like INSERT INTO table set make = "Ford", model = "Explorer"; If you want it to be a drop down box, you will need a little more work, but it is still pretty easy to do. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367765 Share on other sites More sharing options...
PFMaBiSmAd Posted August 8, 2012 Share Posted August 8, 2012 @scm22ri, you somehow managed to start a new thread in the mysql forum section with what is now reply #5 in this thread. Since that appears to be intended as a reply for this thread, I merged that thread into this thread. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367768 Share on other sites More sharing options...
Mahngiel Posted August 8, 2012 Share Posted August 8, 2012 Depending on how you arrive at "Ford Explorer" being the make/model, you can do this two ways. You can either carry over the make and model in the query string ($_GET) or you can make hidden form fields. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367777 Share on other sites More sharing options...
Christian F. Posted August 8, 2012 Share Posted August 8, 2012 I'd use a session variable, to be honest. No need to send data which isn't meant to be manipulated by the user, to the user. In fact, it can be quite detrimental, as mentioned earlier in the thread. Quote Link to comment https://forums.phpfreaks.com/topic/266791-_get-variable-with-auto-populated-content/#findComment-1367783 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.