Jump to content

My code is a world issue


Spiew

Recommended Posts

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!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/278402-my-code-is-a-world-issue/
Share on other sites

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.

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.

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 => [email protected] [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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.