PHP OOP Login/Register System: Flashing (Part 13/23)

preview_player
Показать описание

Official site

Twitter
Рекомендации по теме
Комментарии
Автор

never heard of flashing before! really happy for this course!

MrBledi
Автор

Just FYI, I put Javascript at the top of my register.php file to help with creating category/subcategory auto-populated fields.  I kept getting "headers already sent (output started.... " warnings.  Once I put ob_start() at the top of init.php I could finally get the Session:flash message.

I got a blank white page just as you did.  When I processed register.php again, it worked!  Thanks for the great tutorials!

westcrosby
Автор

Copy paste this code to fix the blank page problem.

register.php
session::put('success', 'You registered successfully');
header('Location: index.php');
session.php
remove the else statement from the flash function
index.php
echo session::flash('success');

That should fix your blank page problems :)

VEFiestA
Автор

I had awful problems with the form not redirecting : do not put a freaking space between Location and :
It must be header('Location: index.php').
The other problem of the string not flashing on index.php is because in the flash function you don't return the string in the else statement, so if it doesn't exist, it gets created but not returned. I think...
Got mine working this way anyway.

therealzefto
Автор

For some reason when I refresh after I get the "You registered successfully!" on the index.php page, the page stays the same. Is there a delay in time before the string gets deleted?

Educoded
Автор

Shouldn't you escape the cookies contents?
Or is there no possibility to modify such session-cookies with an addon?
-> you could insert and echo php, I think

bFix
Автор

It didnt worked before with that white screen, because to set the session you have to do it twice actually..I mean forst it will set but second time it will show only..

GwidazMan
Автор

One of the reasons some of you hit the Register button & it does "nothing", is that you probably did not assign the proper value to the 'name' attribute of the hidden input element for the token, which in this example is 'token'.
Rare error but happens.

wrongbet
Автор

Are some of this abstraction layers really necessary?

mojajojajo
Автор

Having the same problems as others with the page not redirecting. The only solution that worked for me is having ob_start(); as the first bit of code on the register page. Not sure what repercussions this may have though.

familysuitcase
Автор

Can someone help me out?? nothing happens when i click register! no errors warning no nothing...

BigyanGautamphobic
Автор

For the flesh method to flash a message after adding it, you need to return the new message in inside the else block.

e.g;
(re-add the .com)
pastebin com/8YyC5Pzu

LynxaaOG
Автор

Thanks for the reply,
i tried the code at the URl you send, but it did not work for me, still redirected to index.php without the flash message

marlowthebest
Автор

Excuse Me The "You registered successfully!" doesn't pop-up on the index.php. Can you please help me. I stuck on this.

Codecourse please I need your help.

japjap
Автор

Why aren't you using the database for such functionality btw.?

bFix
Автор

PLEASE note if you are hung up on this video and your website is not working right, but you got the same errors as the lecturer move on to the next video he does a similar command that you can use that resolves the problem. DON'T fret over it. Figured it out on my own. 

Warm regards people * smiles *

Jessie-nwej
Автор

When I hit register, I get the same registration page with username and name fields filled and only after filling passwords second time and hitting Register button again I'm redirected to index page. Everything else works just fine. Anyone knows what could be the problem? Tnx

gothmoggamaliel
Автор

Need your help here folks, im always getting this Fatal error: Call to a member function count() on a non-object in on line 45 every time i click on register button.

Mchaker
Автор

alex i have learnt php from you, you are the greatest teacher. but i don't understand why always using static methods? why don't you use just public methods? static is a class level and on different users  it may cause bugs, when non-static methods will be object  level and  specific for each user. it is too much confusing

nikajavakhishvili
Автор

i made it work only if the $string = null, when my $string  = '' in the function, then i had the blank page, i dont know why is that, but when i changed it to null, its all good now, try it out

artmix