Jump to content

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting


AdRock

Recommended Posts

I have a form with validation that works but i want to seperate php from html.

 

I include the form where i want it and have the php included at the top of the page so th ephp is processed before any html is printed

 

Since doing this i get this error message

 

PHP Parse error:  syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']'

 

How do i get around this error?  It's pointing to this line

 

$postcode = check_input($_POST['postcode']);

 

And here is the code in question (the first part)

 

<?php
    global $error, $print_again, $register;
    global $first_name, $last_name;
    global $houseno, $street, $town, $county, $postcode, $telephone;
    global $email1, $email2, $username, $password1, $password2; 

    $register = $_POST['register'];

function check_form() { 

    //variables for checking the user's name
    $first_name = check_input($_POST['first_name']);
    $last_name = check_input($_POST['last_name']);

    //variable for checking the user address and telephone
    $houseno = check_input($_POST['houseno']);
    $street = check_input($_POST['street']);
    $town = check_input($_POST['town']);
    $county = check_input($_POST[county']);
    $postcode = check_input($_POST['postcode']);
    $telephone = check_input($_POST['telephone']);

    //variables for checking the user's email
    $email1 = check_input($_POST['email1']);
    $email2 = check_input($_POST['email2']);

    //varaibles for checking the user login credentials
    $username = check_input($_POST['username']);
    $password1 = check_input($_POST['password1']);
    $password2 = check_input($_POST['password2']);

 

and if you need to see this

 

<?php 

error_reporting(E_ALL);

// check the $_GET['page'] variable
$page = ((isset($_GET['page']) && $_GET['page'] != '') ? $_GET['page'] : 'home');
// prevent file browsing
$page=(preg_match('/(\.\.|\/)/i',$page)?'home':$page);
// replace illegal characters
$page = preg_replace('/[^a-zA-Z0-9 \._-]/','',$page);
// check if the requested file exists
$page = (file_exists('./pages/'.$page.'.php') ? $page : 'error');
// include the page include for page title and functions
include_once('./pages/'.$page.'.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>

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.