PHP Tutorials: Register & Login (Part 11): Register Users (Part 2)

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

Official site

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

thank you so much I went through all the tutorials and i have a working database! can't thank you enough

VinceFromNL
Автор

Thank you very much, that solved the issue, thought I had gone through it all. Saved my sanity for another day.

dashbyictfd
Автор

For anyone struggling with Headers:

- So I had issues with header info so I used OB_Start, and allowed me to login having two headers active, but diminished the ability to register for some reason, I was given a blank page.

- People (myself included) wanted to make the page styled [of course] when a login error were to present itself, and added the Header Include at top. But all math-like functions however (this time, being the Header-Redirect), must be done before output is displayed, so I moved Header-include below the Else statement for Login Output Errors being declared.

- In the login.php file, I added:

if (empty($errors) === false) {
include 'includes/header.php';
?>

- And of course followed by...

<h2>login error:</h2>
<?php
echo output_errors($errors);
?>

- And a footer.php include at the end.

EDIT: Since Init.php is still needed at the top, I left it declared at the top but made an alternative header file that excluded init.php line of code. It all works smooth and was the only easy work-around my noobness could manage. Hope this helps someone.

ReEDIT: After noticing late videos to this one, I realized the fault was in my own for combining init.php in the header.php

Zfyant
Автор

You sir are a gentleman. Thank you kindly!

iamlaners
Автор

It's kind of complicated to show in 500 characters! To make the login password and DB password match: I removed the md5 hash from the register_user function (users.php), put md5s before 'password' and 'password_again' in the $required_fields variable (register.php), and put md5 before 'password' in the $register_data array (also in"register.php"). - Everything works great now.

bluecafe
Автор

If you are having a hard time getting the successful greeting, watch this video he did (can't put in web address here, just type "Beginner PHP Tutorial - 64 - ob_start" into search above, and it is the first video that pops up. Don't need the flush at the bottom, just the ob_start(); at the top. The problem was with the header(); function. You can't have any header tags in the webpage if you are trying to redirect to another page using header(Location: );

TheDouceHouse
Автор

This worked for me on the header issue. Added ob_start(); into the top of my first php tag then added ob_end_flush(); to the end of the php script that is in the body ad returns the header redirect to the register success.
Is this a proper fix or is it not secure?

johnpeterson
Автор

That worked perfect! Thank you :) Just out of curiosity what does that do / will it affect anything else in the script?

iamlaners
Автор

Worked for me, everything is perfect so far!!! : )

modulo
Автор

if you have the follwoing problem you need to add on  \includes\overall\header.php

Warning: Cannot modify header information - headers already sent by (output started at

<?php
ob_start();
?>
and on the footer you need to add
\includes\overall\footer.php
<?php      include 'includes/footer.php';?>
<?php
ob_end_flush();
?>

anchwadumu
Автор

make sure these fields are in your database, ps you don't need to pass the variable password_again, into the database as its used just for password checking reference

IrishAfricanDude
Автор

Hey Alex!

Wouldn't it be good practice to implement some form of captcha also before submitting the content into the database?

Cheers!

Swinkid
Автор

That feeling when you scroll down to see his codes but instead scrolls down this youtube page. lol

chreezzzzzy
Автор

if u having problem with header already sented i resolve that with :

<?php
ob_start();
include "core/init.php";

so u need to use ob_start(); on first line of code.. and should work.. if not then u have to find answer somehow like i tested :p

DamirMutap
Автор

How would I be able to have the 'Login failed' text show under my 'aside' section?

ellejay
Автор

My code looks exactly the same way, but why on the video there is html input h1Register/h1 and the redirecting is working (the header)? Alex, if you could advise on this it will be great!

murkata
Автор

Did you solve that problem? I am having the same issue.

bluecafe
Автор

Alex, great stuff. These videos are top notch.
I am getting '$' output in front of the field names using the echo and the SQL output. My code is exactly like your example. (I'm using Eclipse Juno)
Any ideas? Can you help?
Thanks.

highpointstudios
Автор

just a quick addition from me :)
where you have:
if (isset($_GET['success']) && empty($_GET['success']))
replace with
if (isset($_GET['success']) && empty($_GET['success']) && $_POST)
so when a user enters manually it won't show "Registration successful", but will show normal registration page :))

Peshyy
Автор

Hi phpacademy, my header redirection is not working and it is exactly the same you have in your example... i removed all the html stuff before it and put it in the output area (below all the php stuff)...can you give me any clue? i managed to fallow all the parts from the tutorial but i always get troubles when it comes to headers.... thanks in advance!

majestade