Salve.
Sto tentando di capire dove sia e quale sia l'errore in questo script per fare il login:
codice:
<?php
require 'formhelpers.php';
// Questo è identico alla funzione input_text() in formhelpers.php ma
// stampa una casella di password in cui gli asterischi nascondono quanto
// inserito, invece di un normale campo di testo
function input_password($field, $value){
print '<input type="password" name=""'. $field_name.'"value="';
print htmlentities($value[$field_name]) . '">';
//----------
session_start();
if ($_POST['_submit_check']){
if ($form_errors = validate_form()){
show_form($form_errors);
}else{
process_form();
}
}else{
show_form();
}
//--------
function show_form($errors =''){
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
if ($errors){
print '<ul>[*]';
print implode('[*]',$errors);
print '[/list]';
}
print 'Username: ';
input_text('username', $_POST);
print '</br>';
print 'Password: ';
input_password('password', $_POST);
print '</br>';
input_submit('submit', 'Log In');
print '<input type="hidden" name="_submit_check" value="1"/>';
print '</form>';
}
//------
function validate_form(){
$errors = array();
// Alcuni nomi utenti e passwords di esempio
$users = array('alice' => 'dog123',
'bob' => 'my^pwd',
'charlie' => '**fun**');
//----- Controlla che il nome utente sia valido
if (! array_key_exists($_POST['username'], $users)){
$errors[] = 'Please, enter valid username and password.';
}
//----- Vede se la password è corretta
$saved_password = $users[$_POST['username']];
if (saved_password != $_POST['password']){
$errors[] = 'Please, enter valid username and password.';
}
return $errors;
}
//--------// Aggiunge il nome utente alla sessione
function process_form(){
$_SESSION['username']= $_POST['username'];
print 'Welcome, '. $_SESSION['username'];
}
?>
L'errore che genera è questo:
codice:
Parse error: syntax error, unexpected $end in C:\Xampp_7\xampp\htdocs\login\login.php on line 65
Praticamente sull'ultima riga.
Grazie di qualsiasi consiglio.