error PHP Tutorial: Reg & Login (User Act System) [part 4]

Ask about a PHP problem here.
Post Reply
Posts: 1
Joined: Tue Jul 02, 2013 5:50 pm

error PHP Tutorial: Reg & Login (User Act System) [part 4]

Post by cohenj »

Hello Jacek,

I am following your User Account System Youtube tutorials and I am stuck when I am trying to complete Part 04.

Whenever I run my register.php file, I get an error in Firefox that says: "The character encoding of the HTML document was not declared..."

Now I've come to realize that when I have my PHP code before the HTML code, I get this error. If I remove the PHP code, my page appears. Do you have any suggestions on how I can get my page displayed but also have the PHP code there?

My code is:

[syntax=php]<? php

$errors = array();

if(isset($_POST['fullname'], $_POST['email'])){

$errors[] = 'The full name field cannot be empty.';

$errors[] = 'The email field cannot be empty.';

$errors[] = 'The email you entered is already taken.';
if (empty($errors)){
add_user($_POST['fullname'], $_POST['email']);
$_SESSION['fullname'] = htmlentities($_POST['fullname']);
header('Location: index.php');

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta content="utf-8" http-equiv="encoding" />
<form action="" method="post">
<h1> Register</h1>

if(empty($errors) === false){
foreach ($errors as $error){
echo "<li>{$error}</li>";}
<label for="fullname">Your Full Name</label>
<input id="fullname" name="fullname" required="required" type="text"/>
<label for="email"> Your email</label>
<input id="email" name="email" required="required" type="email" />

input type="submit" value="Sign up"/>


Please help!

Thank you,

Last edited by Helx on Tue Jul 02, 2013 6:32 pm, edited 1 time in total.
Reason: Code tags
Post Reply