unistake Posted January 28, 2009 Share Posted January 28, 2009 is there a quick way to put $_POSTs in to variables securely without using extract($_POST); !!? the only other way i know is $user = $_POST['user']; $reg = $_POST['reg']; etc etc are there any other ways. eg put all $_POSTS in to one array or something? cheers once again Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/ Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 $post_array = $_POST; Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749072 Share on other sites More sharing options...
unistake Posted January 29, 2009 Author Share Posted January 29, 2009 $post_array = $_POST; ok, then can you explain what? would it be like $post_array[user] and $post_array[reg] thanks Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749074 Share on other sites More sharing options...
.josh Posted January 29, 2009 Share Posted January 29, 2009 well if you're not going to validate them, then why not just do extract? Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749076 Share on other sites More sharing options...
.josh Posted January 29, 2009 Share Posted January 29, 2009 $post_array = $_POST; really. What is the difference between doing that and just using $_POST? Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749078 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 Nothing, but the question was to put $_POST into an array. Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749079 Share on other sites More sharing options...
unistake Posted January 29, 2009 Author Share Posted January 29, 2009 dont ask me! gevans: i am going to put the variables in to a INSERT query and send to mysql. I dont really have a clue with arrays and how they work. Ive just been told that extract $_POST is dangerous and creates an open door. do you have any ideas for what i need to do? I have lots of posted information, that i need to put in to an INSERT query Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749080 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 If you want to secure everythig quickly use something like this (assuming their all strings); <?php foreach($_POST as $key => $value) { $post_array[$key] = mysql_real_escape_string($value); } Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749081 Share on other sites More sharing options...
unistake Posted January 29, 2009 Author Share Posted January 29, 2009 that looks good, i'll give it a go thanks gevan Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749083 Share on other sites More sharing options...
unistake Posted January 29, 2009 Author Share Posted January 29, 2009 . Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749084 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 That would put each value into its own variable, but it will not have escaped anything. This will not be secure against sql injection Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749085 Share on other sites More sharing options...
unistake Posted January 29, 2009 Author Share Posted January 29, 2009 That would put each value into its own variable, but it will not have escaped anything. This will not be secure against sql injection ok cheers. i'll give yours a try Quote Link to comment https://forums.phpfreaks.com/topic/142879-quick-way-to-put-_posts-in-to-variables/#findComment-749086 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.