Spiew Posted May 26, 2013 Share Posted May 26, 2013 Hello, Just to mention, I started with PHP in february I think. Now I've come across a problem that none of my friends can help me solve, so I thought of posting it here in hope of saving my life. I'm making a registrationscript. This is my code: login.php - http://pastebin.com/RDhHFX3t functions.php - http://pastebin.com/mMRxxwqC The problem I have, is that it never gets through. It always shows the else message in the login.php file which is "Populate all the fucking fields." Please, save my life by helping me solve this problem. If I ever get the opportunity to meet you who solved this, I'll hug you. Peace! Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 26, 2013 Share Posted May 26, 2013 In the future, please post just the relevant code here, in code tags. You also need to better describe your problem. What "never gets through"? What part of your code is the problem? Try some debugging by doing a print_r($_POST) before your if(isset()) part, and see just what part isn't set. Also use && not and. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 26, 2013 Share Posted May 26, 2013 (edited) you need to troubleshoot WHY your code is not doing what you expect. you know, actually examine the values that are being tested that cause it to take the execution branch that it is. i'll give you a hint, you have far too much logic. you need just the right amount of logic, not too little or too much (edit: because typing or copy/pasting excess amounts of code often leads to mistakes and you have one in a post variable name.) text/textarea from fields that have been submitted will be set. once you test that your form has been submitted, with if (isset($_POST['register'])) {, you don't need to test if each field is set and if your fields are all required, you should individually test if each one contains expected content and output a specific error message for each one that doesn't. Edited May 26, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Spiew Posted May 26, 2013 Author Share Posted May 26, 2013 In the future, please post just the relevant code here, in code tags. You also need to better describe your problem. What "never gets through"? What part of your code is the problem? Try some debugging by doing a print_r($_POST) before your if(isset()) part, and see just what part isn't set. Also use && not and. Uhmkay, Changed to &&. And I've already done print_r($_POST) and it shows Array ( [first_name] => first [last_name] => last => test@gadaw.com [password] => hej [password_repeat] => hej [country] => Barbados [city] => city [zip_code] => 23232 [billing_address] => hemma [mobile_number] => 2323232 [register] => Register ) you need to troubleshoot WHY your code is not doing what you expect. you know, actually examine the values that are being tested that cause it to take the execution branch that it is. i'll give you a hint, you have far too much logic. you need just the right amount of logic, not too little or too much (edit: because typing or copy/pasting excess amounts of code often leads to mistakes and you have one in a post variable name.) text/textarea from fields that have been submitted will be set. once you test that your form has been submitted, with if (isset($_POST['register'])) {, you don't need to test if each field is set and if your fields are all required, you should individually test if each one contains expected content and output a specific error message for each one that doesn't. So you mean I should remove all the if (isset($_POST['first_name'], $_POST['last_name']..................... because it's not needed? Don't I have to change my function also then? Or shall I keep it as it is? register_user($_POST['first_name'], $_POST['last_name']................ Thanks for the answers so far Quote Link to comment Share on other sites More sharing options...
jcbones Posted May 26, 2013 Share Posted May 26, 2013 What is meant is, if 1 variable from the form is set, then all the variables will be set. You need to make sure the form is sending the variables though, but that is where sanitation and validation comes into play. Quote Link to comment Share on other sites More sharing options...
Spiew Posted May 26, 2013 Author Share Posted May 26, 2013 I don't care if something comes into play. ANd I don't care about hints. Gtfo Quote Link to comment Share on other sites More sharing options...
anikwa Posted May 26, 2013 Share Posted May 26, 2013 I often find that when seeking help from people who volunteer their time that it is often best to be pleasant and listen to what they say. Sometimes they do know more than you do (surprisingly!). On the basis of your last post, I would refuse to help you anymore. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 27, 2013 Share Posted May 27, 2013 (edited) On the basis of your last post, I would refuse to help you anymore. Exactly. As in your own words: Gtfo Edited May 27, 2013 by ignace 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.