Jump to content

unexpected $end


pure_skill_2000

Recommended Posts

Hi i keep gettin this message for the last line of this code, can anyone tell me why my code will not work? The code is below

 

<html>

<head>

<title>Register Online</title>

<style type="text/css">

.error{color:#FF0000; font-wieght: bold;}

</style>

</head>

<body>

<form>

First :

<input type="text" Name="input[]" id="first"> <br>

 

</form>

<?

$page = "register.php";

$input = $_POST['input'];

 

function print_form( ){

global $page, $error, $print_again, $HTTP_POST_VARS;

 

$fields=array("first" => "text",

"last" => "text",

"age" => "text",

"email_required" => "text",

"login_required" => "text",

"password1_required" => "password",

"password2_required" => "password");

$labels = array("first" => "First Name",

"last" => "Last Name",

"age" => "Age",

"email_required" => "Email",

"login_required" => "Desired Username",

"password1_required" => "Password",

"password2_required" => "Confirm Password");

?>

<form method="post" action=" <?echo $_SERVER[ "PHP_SELF" ]?>">

<?

if($print_again){

?><h1>You have incorrectly completed some of the fields.

Please correct the <span class=error>red</span> fields.

Passwords must match.<?

}else{

?><h1>Please fill in the following fields.</h1><?

}

?>

<table border ="0">

<?

foreach($fields as $key => $value) {

?>

<tr><td></td> <? error_flag($error, $key);

?><?=$labels[$key]?>:</td>

<td>input type="<?=$value?>" name="<?=$key?>"

value="<? @print($HTTP_POST_VARS[$key])?>"></td></tr>

<?

}

?>

<tr><td colspan="2"><input type="submit" name="submit" value="submit"></td></tr>

</table>

</form>

<?

} //end function print_form

 

function error_flag($error, $field){

if($error[$field]){

print("<td class=error>");

}else{

print("<td>");

}

} //end function error_flag

 

function check_form(){

global $error, $print_again, $HTTP_POST_VARS;

$print_again=false;

//Check required fields are entered

foreach ($HTTP_POST_VARS as $key => $value) {

if(($value == "") && eregi("_required$", $key)){

$error[$key]=true;

$print_again=true;

}else{

$error[$key]=false;

}

}

//verify email

if(!eregi("^[a-z0-9]+[a-z0-9_-]*(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.([a-z]+){2,}$",

$HTTP_POST_VARS['email_required'])){

$error['email_required'] = true;

$print_again = true;

$HTTP_POST_VARS['email_required' ] ="Enter a valid EMail";

}

//verify username

if(!eregi("^[a-z0-9]$",

$HTTP_POST_VARS['login_required'])){

$error['login_required'] = true;

$print_again = true;

$HTTP_POST_VARS['login_required' ] ="Enter letters and numbers only";

}

//verify password

if($HTTP_POST_VARS['password1_required'] !=

$HTTP_POST_VARS['password2_required']){

$error['password1_required'] = true;

$error['password2_required'] = true;

$HTTP_POST_VARS['password1_required'] = NULL;

$HTTP_POST_VARS['password2_required'] = NULL;

$print_again = true;

}

//print again if errors

if($print_again){

print_form();

}else{

print("<h1>Thank you for registering</h1>");

}

}

/*****MAIN*****/

if(isset($submit)){

check_form();

}else{?>

<table cellpadding="0" cellspacing="0" border="0">

  <tr>

    <td>First:</td>

    <td><?php echo $_POST['first']; ?></td>

  </tr>

 

</table>

 

}

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/75260-unexpected-end/
Share on other sites

That error is usually caused by a mismatched "{ }".  In your case you don't surround the last "}" with PHP tags:

<?php
}else{?>
<table cellpadding="0" cellspacing="0" border="0">
   <tr>
    <td>First:</td>
    <td><?php echo $_POST['first']; ?></td>
  </tr>

</table>

<?php }  ?>        
</body>
</html>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/75260-unexpected-end/#findComment-380640
Share on other sites

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.