Jump to content

Seeking help with form and realtive php script...


clakes

Recommended Posts

Hello guys,

I'm mostly no PHP-aware, close-to-absolute beginner.

In brief, I generated the script below php-script with Forms to Go in order to get registration data on a 5.0.45-community-log MySQL table (managed thru phpMyAdmin).

Now, when i try to send the data from the form (attached along with the script), Safari returns the following:

 

 

Warning: preg_match() [function.preg-match]: Unknown modifier '\' in /home/caleidoc/public_html/registrazione_cc.php on line 74

 

Warning: preg_match() [function.preg-match]: Unknown modifier '\' in /home/caleidoc/public_html/registrazione_cc.php on line 74

 

Warning: preg_match() [function.preg-match]: Unknown modifier '\' in /home/caleidoc/public_html/registrazione_cc.php on line 74

 

Warning: Cannot modify header information - headers already sent by (output started at /home/caleidoc/public_html/registrazione_cc.php:74) in /home/caleidoc/public_html/registrazione_cc.php on line 314

 

 

I'm clueless. I've previously and successfully used the same application for generating a (less "complicated") similar script.

The output script is the following:

 

<?PHP
######################################################
#                                                    #
#                Forms To Go 3.2.5                   #
#             http://www.bebosoft.com/               #
#                                                    #
######################################################



DEFINE('kOptional', true);
DEFINE('kMandatory', false);

DEFINE('kStringRangeFrom', 1);
DEFINE('kStringRangeTo', 2);
DEFINE('kStringRangeBetween', 3);
DEFINE('kYes', 'yes');
DEFINE('kNo', 'no');




error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);

function DoStripSlashes($FieldValue) 
{ 
if ( get_magic_quotes_gpc() ) { 
  if (is_array($FieldValue) ) { 
   return array_map('DoStripSlashes', $FieldValue); 
  } else { 
   return stripslashes($FieldValue); 
  } 
} else { 
  return $FieldValue; 
} 
}

#----------
# FilterCChars:

function FilterCChars($TheString)
{
return preg_replace('/[\x00-\x1F]/', '', $TheString);
}

#----------
# Validate: String

function check_string($value, $low, $high, $mode, $limitalpha, $limitnumbers, $limitemptyspaces, $limitextrachars, $optional)
{
if ($limitalpha == kYes) {
  $regexp = 'A-Za-z';
}

if ($limitnumbers == kYes) {
  $regexp .= '0-9'; 
}

if ($limitemptyspaces == kYes) {
  $regexp .= ' '; 
}

if (strlen($limitextrachars) > 0) {

  $search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|');
  $replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|');

  $regexp .= str_replace($search, $replace, $limitextrachars);

}

if ( (strlen($regexp) > 0) && (strlen($value) > 0) ){
  if (preg_match('/[^' . $regexp . ']/', $value)) {
   return false;
  }
}

if ( (strlen($value) == 0) && ($optional === kOptional) ) {
  return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
  return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
  return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
  return true;
} else {
  return false;
}

}


#----------
# Validate: Email

function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
  return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
  return true;
} else {
  return false;
}
}


#---------------
# Validate: Date

function check_dateformat($value, $optional)
{
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
  return true;
}

$year = substr($value, '6', '2');
$month = substr($value, '3', '2');
$day = substr($value, '0', '2');

if ( @checkdate($month, $day, $year) ) {
  return true;
} else {
  return false;
}
}



if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGnome = DoStripSlashes( $_REQUEST['nome'] );
$FTGcognome = DoStripSlashes( $_REQUEST['cognome'] );
$FTGluogonascita = DoStripSlashes( $_REQUEST['luogonascita'] );
$FTGdatanascita = DoStripSlashes( $_REQUEST['datanascita'] );
$FTGresidenza = DoStripSlashes( $_REQUEST['residenza'] );
$FTGindirizzo = DoStripSlashes( $_REQUEST['indirizzo'] );
$FTGemail = DoStripSlashes( $_REQUEST['email'] );
$FTGtelefono = DoStripSlashes( $_REQUEST['telefono'] );
$FTGprofessione = DoStripSlashes( $_REQUEST['professione'] );
$FTGInvia = DoStripSlashes( $_REQUEST['Invia'] );


# Fields Validations

$ValidationFailed = false;

if (!check_string($FTGnome, 3, 30, kStringRangeBetween, kYes, kNo, kYes, '\'äüïöëÇñßóÖÑçåãâPrego, inserisci un nome valido.îôõûæœøØÆÿŸËÊÂ', kMandatory)) {
$ValidationFailed = true;
}
if (!check_string($FTGcognome, 2, 40, kStringRangeBetween, kYes, kNo, kYes, '\'äüïöëÇñßóÖÑçåãâPrego, inserisci un nome valido.îôõûæœøØÆÿŸËÊÂ', kMandatory)) {
$ValidationFailed = true;
}
if (!check_string($FTGluogonascita, 3, 50, kStringRangeBetween, kYes, kNo, kYes, '\'äüïöëÇñßóÖÑçåãâPrego, inserisci un nome valido.îôõûæœøØÆÿŸËÊÂ', kMandatory)) {
$ValidationFailed = true;
}
if (!check_dateformat($FTGdatanascita, kMandatory)) {
$ValidationFailed = true;
}
if (!check_string($FTGresidenza, 3, 40, kStringRangeBetween, kYes, kNo, kYes, '\'äüïöëÇñßóÖÑçåãâPrego, inserisci un nome valido.îôõûæœøØÆÿŸËÊÂ', kMandatory)) {
$ValidationFailed = true;
}
if (!check_string($FTGindirizzo, 6, 60, kStringRangeBetween, kYes, kYes, kYes, '\'äüïöëÇñßóÖÑçåãâPrego, inserisci un nome valido.îôõûæœøØÆÿŸËÊÂ/()-', kMandatory)) {
$ValidationFailed = true;
}
if (!check_email($FTGemail, kMandatory)) {
$ValidationFailed = true;
}
if (!check_string($FTGtelefono, 6, 17, kStringRangeBetween, kNo, kYes, kNo, '/+()-', kOptional)) {
$ValidationFailed = true;
}
if (!check_string($FTGprofessione, 4, 60, kStringRangeBetween, kYes, kNo, kYes, '/-(),', kMandatory)) {
$ValidationFailed = true;
}


# Redirect user to the error page

if ($ValidationFailed === true) {

header("Location: http://www.caleidoclub.com/registrazione_errore.html");
exit;

}
# Email to Form Owner

$emailSubject = FilterCChars("$FTGnome $FTGcognome richiede compilazione modulo associazione");

$emailBody = "Dati forniti:\n"
. "\n"
. "nome : $FTGnome\n"
. "cognome : $FTGcognome\n"
. "luogonascita : $FTGluogonascita\n"
. "datanascita : $FTGdatanascita\n"
. "residenza : $FTGresidenza\n"
. "indirizzo : $FTGindirizzo\n"
. "email : $FTGemail\n"
. "telefono : $FTGtelefono\n"
. "professione : $FTGprofessione";
$emailTo = 'Francesco Fiore <[email protected]>';
  
$emailFrom = FilterCChars("$FTGemail");
  
$emailHeader = "From: $emailFrom\n"
  . "MIME-Version: 1.0\n"
  . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
  . "Content-transfer-encoding: 8bit\n";
  
mail($emailTo, $emailSubject, $emailBody, $emailHeader);


# Confirmation Email to User

$confEmailTo = FilterCChars($FTGemail);

$confEmailSubject = FilterCChars("Conferma dati forniti per la registrazione presso l'Associazione Caleido Club");

$confEmailBody = "Ciao $FTGnome!\n"
. "\n"
. "   Ti ringraziamo per averci inviato i tuoi dati.\n"
. "\n"
. "La compilazione del Modulo di Associazione richiederà da un minimo di 1 ad un massimo di 5 giorni lavorativi.\n"
. "Una volta che accederai ai locali dell'Associazione, potrai richiedere il modulo dichiarando il tuo nome e cognome, firmare lo stesso e ricevere subito la Tua tessera di Socio.\n"
. "\n"
. "I tuoi dati personali sono i seguenti:\n"
. " \n"
. "Nome : $FTGnome\n"
. "Cognome : $FTGcognome\n"
. "Luogo di Nascita : $FTGluogonascita\n"
. "Data di Nascita : $FTGdatanascita\n"
. "Residenza in : $FTGresidenza\n"
. "Indirizzo : $FTGindirizzo\n"
. "Email : $FTGemail\n"
. "Telefono : $FTGtelefono\n"
. "\n"
. "In caso di errato inserimento, ti preghiamo di non inviare nuovamente i tuoi dati in nessun modo: avrai occasione di correggerli assieme ad un nostro incaricato presso la nostra Sede.\n"
. "\n"
. "A presto!\n"
. "\n"
. "\n"
. "Associazione Caleido Club\n"
. "Via Enrico Mattei 48/G\n"
. "40138 Bologna\n"
. "Italia";

$confEmailHeader = "From: [email protected]\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 8bit\n";

mail($confEmailTo, $confEmailSubject, $confEmailBody, $confEmailHeader);

#====================================================
# Dump field values to a MySQL table                =
#====================================================

$mysql_link = @mysql_connect("62.149.150.67", "Sql164681", "0513cf60");


if (mysql_errno() == 0) {

@mysql_select_db("Sql164681_4", $mysql_link);


}

if (get_magic_quotes_gpc()) {
$FTG_nome = stripslashes($FTGnome);
$FTG_cognome = stripslashes($FTGcognome);
$FTG_luogonascita = stripslashes($FTGluogonascita);
$FTG_datanascita = stripslashes($FTGdatanascita);
$FTG_residenza = stripslashes($FTGresidenza);
$FTG_indirizzo = stripslashes($FTGindirizzo);
$FTG_email = stripslashes($FTGemail);
$FTG_telefono = stripslashes($FTGtelefono);
$FTG_professione = stripslashes($FTGprofessione);
} else {
$FTG_nome = $FTGnome;
$FTG_cognome = $FTGcognome;
$FTG_luogonascita = $FTGluogonascita;
$FTG_datanascita = $FTGdatanascita;
$FTG_residenza = $FTGresidenza;
$FTG_indirizzo = $FTGindirizzo;
$FTG_email = $FTGemail;
$FTG_telefono = $FTGtelefono;
$FTG_professione = $FTGprofessione;
}

if (mysql_errno() == 0) {

$sqlcmd = sprintf("INSERT INTO `registrazione_cc`(`nome`, `cognome`, `luogonascita`, `datanascita`, `residenza`, `indirizzo`, `email`, `telefono`, `professione`, `useragent`, `remoteaddress`, `datetime`) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
                   mysql_real_escape_string($FTG_nome, $mysql_link),
                   mysql_real_escape_string($FTG_cognome, $mysql_link),
                   mysql_real_escape_string($FTG_luogonascita, $mysql_link),
                   mysql_real_escape_string($FTG_datanascita, $mysql_link),
                   mysql_real_escape_string($FTG_residenza, $mysql_link),
                   mysql_real_escape_string($FTG_indirizzo, $mysql_link),
                   mysql_real_escape_string($FTG_email, $mysql_link),
                   mysql_real_escape_string($FTG_telefono, $mysql_link),
                   mysql_real_escape_string($FTG_professione, $mysql_link),
                   mysql_real_escape_string($_SERVER['HTTP_USER_AGENT'], $mysql_link),
                   mysql_real_escape_string($ClientIP, $mysql_link),
                   mysql_real_escape_string(date('Y-m-d H:i:s'), $mysql_link));

@mysql_query($sqlcmd, $mysql_link);


}

# Redirect user to success page

header("Location: http://www.caleidoclub.com/registrazione_conferma.html");
exit;
?>

 

The line (74) involved is:

 

  if (preg_match('/[^' . $regexp . ']/', $value)) {

 

Any help is heartedly appreciated, I need the thing to be running in days. Might even consider shelling out a small donation.

Thanks in advance.

 

[attachment deleted by admin]

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.