TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login GOLD PRICE, RATE
login HOROSCOPE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login FINANCE, BUSINESS
login WORLD COUNTRIES, WIKI

PHP scripts, code, examples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

PHP. Form validation, submit, confirm, insert, update, send email

 Initial code contains 3 operations, based on variable $_GET['oE'] or $_POST['oE']:
<?php

global $_GET, $_POST, $_GP, $_SESSION, $_SERVER, $folder, $index, $indexFiles;

error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);

###################################################
#                                                 #
#                 Parameters                      #
#                                                 #
###################################################

$folder     = "/_www_ftp/www_conf/_files/registrationForm";
$index      = "http://conf.kolegija.lt/registration";
$indexFiles = "http://conf.kolegija.lt/_files/registrationForm";

###################################################
#                                                 #
#                      Code                       #
#                                                 #
###################################################

$_SESSION['formLock']++;
if ($_SESSION['formLock'] > 200)
    exit();

$link = mysql_connect('localhost', 'joomla_conf', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("joomla_conf", $link);


foreach ($_GET as $k => $v) {
    
    $_GET[$k] = mysql_real_escape_string(strip_tags($v, ""));
    
}

foreach ($_POST as $k => $v) {
    
    $_POST[$k] = mysql_real_escape_string(strip_tags($v, ""));
    
}

// print_r($_GET);

$_GPS = array_merge($_SESSION, $_POST, $_GET);
$_GP  = array_merge($_POST, $_GET);

//print_r ($_GP);

extract($_GP);

if ($oE == 1) {
    
    if (!trim($titlename)) {
        $err .= "No Title and Name. ";
    }
    
    if (!trim($organization)) {
        $err .= "No Organization. ";
    }
    
    if (!trim($organization)) {
        $err .= "No Address. ";
    }
    
    if (!$earlyRegistration) {
        $err .= "No Fee selected. ";
    }
    
    $expression = "/^[a-zA-Z0-9._-][email protected][a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$/";
    if (!preg_match($expression, $email)) {
        $err .= "No Email or bad Email. ";
    }
    
    if (!$subsection or !$oralPresentation or !$posterPresentation or !$withoutPresentation or !$promotionalMaterials) {
        $err .= "Please fill participation information. ";
    }
    
    $ext          = array(
        "pdf",
        "doc",
        "docx",
        "odt",
        "jpg",
        "jpeg",
        "png"
    );
    $biodata      = pathinfo($_FILES['biodata']['name']);
    $photo        = pathinfo($_FILES['photo']['name']);
    $abstractFile = pathinfo($_FILES['abstractFile']['name']);
    
    if (!in_array(strtolower($biodata["extension"]), $ext) and $_FILES['biodata']['name']) {
        $err .= "Not valid biodata file extention. ";
    }
    
    if (!in_array(strtolower($photo["extension"]), $ext) and $_FILES['photo']['name']) {
        $err .= "Not valid photo file extention. ";
    }
    
    if (!in_array(strtolower($abstractFile["extension"]), $ext) and $_FILES['abstractFile']['name']) {
        $err .= "Not valid abstract file extention. ";
    }
    
}

//echo "sub" . $subsection;

if ($err) {
    unset($oE);
    $err = "<font color = red size = \"4\" >$err Please confirm files again.</font>";
}

#

if (!$oE) {
    
    eval(" \$c_$subsection =\" checked = checked \" ; ");
    
    eval(" \$e_$earlyRegistration =\" checked = checked \" ; ");
    
    if ($oralPresentation == "Yes") {
        $oYes = "checked = checked ";
    }
    if ($oralPresentation == "No") {
        $oNo = "checked = checked ";
    }
    
    if ($posterPresentation == "Yes") {
        $pYes = "checked = checked ";
    }
    if ($posterPresentation == "No") {
        $pNo = "checked = checked ";
    }
    
    if ($withoutPresentation == "Yes") {
        $wYes = "checked = checked ";
    }
    if ($withoutPresentation == "No") {
        $wNo = "checked = checked ";
    }
    
    if ($promotionalMaterials == "Yes") {
        $prYes = "checked = checked ";
    }
    if ($promotionalMaterials == "No") {
        $prNo = "checked = checked ";
    }
    
    print $err;
    include "incForm.php";
    
} elseIf ($oE == 1) {
    
    include "incInsert.php";
    include "incConfirm.php";
    
} elseIf ($oE == 2) {
    
    include "incUpdate.php";
    include "incInvoice.php";
    
}


?>
INITIAL OPERATION

HTML Form:
<div class = "formRegistration">
<form class = "formRegister" method = "post" enctype = "multipart/form-data" action = "<?php print $index ?>" >

<table border="1" cellspacing="0" cellpadding="0" class="tableOuter"  align = "center" >
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF" >
    <p align="center">
      <strong>REGISTRATION FORM</strong><br />Please submit your registration form by 1 July 2013 if you opt form early registration
      or 10 september 2013 if you opt for late</p>
  </td>
  </tr>
  <tr>
    <td colspan="4" valign="top">
    
    
    <table width="100%" border="1" cellspacing="0" cellpadding="0" class = "tableInner">
    <tr>
<td width="35%"  valign="top"><p><strong>&nbsp;Title and Name:</strong></p></td>
    <td width="65%"  valign="top">
    <p><input name="titlename" type="text" size = "50" value = "<?php print $titlename ; ?>" /></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Organization:</strong></p></td>
    <td  valign="top"><p>
      <input name="organization" type="text"  size = "50" value = "<?php print $organization ; ?>"  />
    </p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Address:</strong></p></td>
    <td  valign="top"><p>
      <input name="address" type="text"  size = "50"  value = "<?php print $address ; ?>" />
    </p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Phone:</strong></p></td>
    <td  valign="top"><p>
      <input name="phone" type="text"  size = "50" value = "<?php print $phone ; ?>"  />
    </p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Mobile:</strong></p></td>
    <td  valign="top"><p>
      <input name="mobile" type="text"  size = "50"  value = "<?php print $mobile ; ?>"  />
    </p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;FAX:</strong></p></td>
    <td  valign="top"><p><strong>
      <input name="fax" type="text"  size = "50"   value = "<?php print $fax ; ?>"  />
    &nbsp;</strong></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;E-mail:</strong></p></td>
    <td  valign="top"><p><strong>
      <input name="email" type="text" size = "50"   value = "<?php print $email ; ?>" />
    &nbsp;</strong></p></td></tr>  
    
    <tr>
    <td  valign="top"><p><strong>&nbsp;Please apply your biodata (pdf, doc, docx, odt):</strong></p></td>
    <td  valign="top"><p><strong>
      <input name="biodata" type="file" size = "50" />
    &nbsp;</strong></p></td></tr>
</table>

    </td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF"><p><strong>CONFERENCE participation    information: please fill the field </strong></p></td>
  </tr>
  <tr>
    <td width="461" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Choose the  section of the conference you would like to participate in</strong></p></td>
    <td colspan="3" rowspan="2" valign="top" bgcolor="#DFDFDF" ><p>&nbsp;Subsection <strong>1A:  Digital linguistics and literature;</strong> <br />
      &nbsp;Subsection <strong>1B:  Translation Studies</strong> ;<br />
      &nbsp;Subsection <strong>1C:  Digital librarianship;</strong><br />
      &nbsp;Subsection <strong>2A:  IT - applied solutions;</strong> <br />
      &nbsp;Subsection <strong>2B:  E-tools;</strong><br />
      &nbsp;Subsection<strong> 3A:  Business process modeling;</strong><br />
      &nbsp;Subsection<strong> 3B:  Virtual learning.</strong></p></td>
  </tr>
  <tr>
    <td width="461" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;1a
      <input name="subsection" type="radio" value="1a" <?php echo $c_1a ;?> />
    </strong><strong>    1b
    <input name="subsection" type="radio"   value="1b" <?php echo $c_1b ;?> />
    </strong><strong>   1c
    <input name="subsection" type="radio"   value="1c" <?php echo $c_1c ;?> />
    </strong><br />
      <strong>&nbsp;2a
      <input name="subsection" type="radio" value="2a" <?php echo $c_2a ;?> />
      </strong><strong>    2b
      <input name="subsection" type="radio" value="2b" <?php echo $c_2b ;?> />
      </strong><strong>      <br />
      &nbsp;3a
      <input name="subsection" type="radio" value="3a" <?php echo $c_3a ;?> />
      </strong><strong>    3b
      <input name="subsection" type="radio" value="3b" <?php echo $c_3b ;?> />
      </strong>
      </p>
      </td>
  </tr>
<tr>
<td colspan="3" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to    make an oral presentation </strong></p></td>
    <td width="" valign="top" bgcolor="#DFDFDF"><nobr>
      <p><strong>&nbsp;Yes 
        <input name="oralPresentation" type="radio" value="Yes" <?php echo $oYes ;  ?> />  No 
        <input name="oralPresentation" type="radio" value="No"  <?php echo $oNo ;  ?> />
    </strong></p></nobr>

</td></tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to    make a poster presentation up to (1x1) m2 </strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Yes 
      <input name="posterPresentation" type="radio" value="Yes" <?php echo $pYes ;  ?> />
      No 
      <input name="posterPresentation" type="radio" value="No"  <?php echo $pNo ;  ?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to    participate in the conference without any presentation </strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Yes 
      <input name="withoutPresentation" type="radio" value="Yes"  <?php echo $wYes ;  ?> />
      No 
      <input name="withoutPresentation" type="radio" value="No"   <?php echo $wNo ;  ?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF" ><p><strong>&nbsp;I am planning to    display promotional materials/handouts (leaflets, booklets, CDs etc.) about    my organisation, research work, projects etc.</strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF" ><p><strong>&nbsp;Yes 
      <input name="promotionalMaterials" type="radio" value="Yes"   <?php echo $prYes ;  ?> />
      No 
    <input name="promotionalMaterials" type="radio" value="No"      <?php echo $prNo ;  ?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF"><p><strong>ABSTRACT OF PRESENTATION:</strong></p></td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#DFDFDF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        
        <table width="100%" border="1" cellspacing="0" cellpadding="0"  class = "tableInner" >
  <tr>
    <td width="35%"  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Abstract title:</strong></p></td>
    <td width="65%"  valign="top" bgcolor="#DFDFDF"><p><strong>
      <input name="abstractTitle" type="text" size = "50" value = "<?php print $abstractTitle ; ?>"  />
    </strong></p></td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Authors:</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
      <input name="abstractAuthors" type="text" size = "50"   value = "<?php print $abstractAuthors ; ?>"  />
    </strong></p></td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Affiliation:</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
      <input name="abstractAffiliation" type="text" size = "50" value = "<?php print $abstractAffiliation ; ?>" />
    </strong></p></td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Abstract file: (pdf, doc, docx, odt)</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
      <input name="abstractFile" type="file" size = "50" /><br />
      The template of full paper is available at <a href = "http://journal.kolegija.lt/?submissions">http://journal.kolegija.lt/?submissions</a>.
    </strong></p></td>
  </tr>  
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Please attach your photo, no less than 15kb (jpg, jpeg, png)</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
      <input name="photo" type="file" size = "50" />
    </strong></p></td>
  </tr>
</table>
        </td>
      </tr>
    </table>      <p><strong>&nbsp;Conference fee (please secify):</strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p>&nbsp;Early registration: students (PhD, MsSC, MA,    MPhil)</p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p>&nbsp;€ 50<strong>
      &nbsp;
      <input name="earlyRegistration" type="radio" value="50" <?php echo $e_50 ;?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p>&nbsp;Early registration: others</p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p>&nbsp;€ 90&nbsp; <strong>
      <input name="earlyRegistration" type="radio" value="90" <?php echo $e_90 ;?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p>&nbsp;Late registration: students (PhD, MsSC, MA,    MPhil)</p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p>&nbsp;€ 70 &nbsp;<strong>
      <input name="earlyRegistration" type="radio" value="70" <?php echo $e_70 ;?> />
    </strong></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p>&nbsp;Late registration: others</p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p>&nbsp;€ 120<strong>
      <input name="earlyRegistration" type="radio" value="120" <?php echo $e_120 ;?> />
    </strong></p></td>
  </tr>

 <tr>
    <td colspan="4" valign="top" bgcolor=""><input value = "SUBMIT" name="" type="submit"></td>
  </tr>
</table>
<input type = "hidden" name = "oE" value = "1" >

</form>
</div>
 
OPERATION 1

insert data, upload files (record is not confirmed yet, but INSERTED!!!). Files are uploaded. Mysql Field "lock" is set to 1. It means- not confirmed.
<?php

$limit = 10000000;
$table = "t_form";

###############################
#                             #
#         PAREMTERS           #
#                             #
###############################

//print_r ($_FILES);
if ($_FILES['abstractFile']["size"] > 0 and $_FILES['abstractFile']["size"] < $limit) {
    $abstractFile = strtr($_FILES["abstractFile"]["name"], " ąčęėįšųūžĄČĘĖĮŠŲŪŽ", "_aceeisuuzACEEISUUZ");
    
    //echo $_FILES["file"]['tmp_name'] . " $folder/$file<br />";
    
    
} else {
    
    unset($abstractFile);
    
}

if ($_FILES['biodata']["size"] > 0 and $_FILES['biodata']["size"] < $limit) {
    $biodata = strtr($_FILES["biodata"]["name"], " ąčęėįšųūžĄČĘĖĮŠŲŪŽ", "_aceeisuuzACEEISUUZ");
    
    //echo $_FILES["file"]['tmp_name'] . " $folder/$file<br />";
    
} else {
    
    unset($biodata);
    
}

if ($_FILES['photo']["size"] > 0 and $_FILES['photo']["size"] < $limit) {
    $photo = strtr($_FILES["photo"]["name"], " ąčęėįšųūžĄČĘĖĮŠŲŪŽ", "_aceeisuuzACEEISUUZ");
    
    //echo $_FILES["file"]['tmp_name'] . " $folder/$file<br />";
    
} else {
    
    unset($photo);
    
}


//echo "<hr> file" . $file . "<br />";  

$fieldsList = "
      `titlename` , 
      `organization` , 
      `address` , 
      `phone`, 
      `mobile`, 
      `fax`,
      `email`, 
      `subsection`, 
      `oralPresentation`, 
      `posterPresentation`, 
      `withoutPresentation`,
      `promotionalMaterials`,
      `abstractTitle`,
      `abstractAuthors`,
      `abstractAffiliation`,
      `earlyRegistration`,
      `biodata`,
      `abstractFile`,
      `photo`,
      `lock`
    ";

$valuesList = "
     '{$_GP['titlename']}' , 
     '{$_GP['organization']}' , 
     '{$_GP['address']}' , 
     '{$_GP['phone']}', 
     '{$_GP['mobile']}', 
     '{$_GP['fax']}',
     '{$_GP['email']}', 
     '{$_GP['subsection']}', 
     '{$_GP['oralPresentation']}', 
     '{$_GP['posterPresentation']}', 
     '{$_GP['withoutPresentation']}',
     '{$_GP['promotionalMaterials']}',
     '{$_GP['abstractTitle']}',
     '{$_GP['abstractAuthors']}',
     '{$_GP['abstractAffiliation']}',
     '{$_GP['earlyRegistration']}',
     '{$biodata}',
     '{$abstractFile}',
     '{$photo}',
      1
    ";
$query  = "insert into $table ($fieldsList) 
    values ( $valuesList )";

echo $query;

$result = mysql_query($query) or die("Invalid query: " . mysql_error());
// echo "Yra" . mysql_affected_rows ( );

$mysqlId = mysql_insert_id();

chdir(getcwd());
mkdir("$folder/$mysqlId");

if ($biodata) {
    
    // echo $folder. "/$mysqlId/" . $biodata . "<hr>";
    copy($_FILES["biodata"]['tmp_name'], $folder . "/$mysqlId/" . $biodata);
    
}

if ($abstractFile) {
    
    // echo $folder. "/$mysqlId/" . $abstractFile . "<hr>";
    copy($_FILES["abstractFile"]['tmp_name'], $folder . "/$mysqlId/" . $abstractFile);
    
}

if ($photo) {
    // echo $folder. "/$mysqlId/" . $photo . "<hr>";    
    copy($_FILES["photo"]['tmp_name'], $folder . "/$mysqlId/" . $photo);
    
}

//$content .= "<script>window.location = '$index?';</script>";


return $content;

?>


Confirmation page:
<div class = "formRegistration">
<form class = "formRegister" method = "post" enctype = "multipart/form-data" action = "<?php print $index ?>" >

<table border="1" cellspacing="0" cellpadding="0" class="tableOuter"  align = "center" >
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF" >
    <p align="center">
      <strong>CHECK REGISTRATION FORM</strong></p>
  </td>
  </tr>
  <tr>
    <td colspan="4" valign="top">
    
    
    <table width="100%" border="1" cellspacing="0" cellpadding="0" class = "tableInner">
    <tr>
<td width="35%"  valign="top"><p><strong>&nbsp;Title and Name:</strong></p></td>
    <td width="65%"  valign="top">
    <p>&nbsp;&nbsp;<?php print $titlename ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Organization:</strong></p></td>
    <td  valign="top">
    <p>&nbsp;&nbsp;<?php print $organization ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Address:</strong></p></td>
    <td  valign="top">
    <p>&nbsp;&nbsp;<?php print $address ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Phone:</strong></p></td>
    <td  valign="top">
    <p>&nbsp;&nbsp;<?php print $phone ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;Mobile:</strong></p></td>
    <td  valign="top">
    <p>&nbsp;&nbsp;<?php print $mobile ; ?></p>
    </td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;FAX:</strong></p></td>
    <td  valign="top"><p>&nbsp;&nbsp;<?php print $fax ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top"><p><strong>&nbsp;E-mail:</strong></p></td>
    <td  valign="top"><p>&nbsp;&nbsp;<?php print $email ; ?></p></td></tr>  
    
    <tr>
    <td  valign="top"><p><strong>&nbsp;Your biodata:</strong></p></td>
    <td  valign="top"><p><strong>
    
    <?php
    
    if ($_FILES['biodata']['name']){
    
    print "&nbsp;&nbsp;" . $_FILES['biodata']['name'];
    
    }else{
    
    print "&nbsp;&nbsp;Not specified";
    
    }
    
    ?>
    &nbsp;</strong></p></td></tr>
</table>

    </td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF"><p><strong>CONFERENCE participation    information</strong></p></td>
  </tr>
  <tr>
    <td width="461" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Choose the  section of the conference you would like to participate in</strong></p></td>
    <td colspan="3" rowspan="2" valign="top" bgcolor="#DFDFDF" ><p>&nbsp;Subsection <strong>1A:  Digital linguistics and literature;</strong> <br />
      &nbsp;Subsection <strong>1B:  Translation Studies</strong> ;<br />
      &nbsp;Subsection <strong>1C:  Digital librarianship;</strong><br />
      &nbsp;Subsection <strong>2A:  IT - applied solutions;</strong> <br />
      &nbsp;Subsection <strong>2B:  E-tools;</strong><br />
      &nbsp;Subsection<strong> 3A:  Business process modeling;</strong><br />
      &nbsp;Subsection<strong> 3B:  Virtual learning.</strong></p></td>
  </tr>
  <tr>
    <td width="461" valign="top" bgcolor="#DFDFDF" valign = "middle" align = "center" ><p>
    <?php print $subsection ; ?>
      </p>
      </td>
  </tr>
<tr>
<td colspan="3" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to make an oral presentation </strong></p></td>
    <td width="" valign="top" bgcolor="#DFDFDF"><nobr>
      <p><?php print $oralPresentation ; ?></p></nobr>

</td></tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to    make a poster presentation up to (1x1) m2 </strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p><?php print $posterPresentation ; ?></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;I would like to    participate in the conference without any presentation </strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p><?php print $withoutPresentation ; ?></p></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF" ><p><strong>&nbsp;I am planning to    display promotional materials/handouts (leaflets, booklets, CDs etc.) about    my organisation, research work, projects etc.</strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF" ><p><?php print $promotionalMaterials ; ?></p></td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#BFBFBF"><p><strong>ABSTRACT OF PRESENTATION:</strong></p></td>
  </tr>
  <tr>
    <td colspan="4" valign="top" bgcolor="#DFDFDF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        
        <table width="100%" border="1" cellspacing="0" cellpadding="0"  class = "tableInner" >
  <tr>
    <td width="35%"  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Abstract title:</strong></p></td>
    <td width="65%"  valign="top" bgcolor="#DFDFDF"><p>&nbsp;&nbsp;<?php print $abstractTitle ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Authors:</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p>&nbsp;&nbsp;<?php print $abstractAuthors ; ?></p></td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Affiliation:</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p>&nbsp;&nbsp;<?php print $abstractAffiliation ; ?></p>
    </td>
  </tr>
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Abstract file:</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
    
    <?php
    
    if ($_FILES['abstractFile']['name']){
    
    print "&nbsp;&nbsp;" . $_FILES['abstractFile']['name'];
    
    }else{
    
    print "&nbsp;&nbsp;Not specified";
    
    }
    
    ?>
    
      </strong></p></td>
  </tr>  
  <tr>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>&nbsp;Your photo</strong></p></td>
    <td  valign="top" bgcolor="#DFDFDF"><p><strong>
    
    <?php
    
    if ($_FILES['photo']['name']){
    
    print "&nbsp;&nbsp;" . $_FILES['photo']['name'];
    
    }else{
    
    print "&nbsp;&nbsp;Not specified";
    
    }
    
    ?>
    
    </strong></p></td>
  </tr>
</table>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="3" valign="top" bgcolor="#DFDFDF"><p>&nbsp;<strong>Conference registration fee: </strong></p></td>
    <td width="412" valign="top" bgcolor="#DFDFDF"><p>&nbsp;&nbsp;€<strong>
      &nbsp;&nbsp;<?php echo $earlyRegistration ;?> 
    </strong></p></td>
  </tr>


 <tr>
    <td colspan="4" valign="top" bgcolor=""><input value = "CONFIRM" name="" type="submit"></td>
  </tr>
</table>
<input type = "hidden" name = "oE" value = "2" >
<input type = "hidden" name = "mysqlId" value = "<?php print $mysqlId;?>" >
</form>
</div>

Confirmed:

<?php

error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);

$table = "t_form";

###############################
#                             #
#         PAREMTERS           #
#                             #
###############################

//print_r ($_FILES);

//echo "<hr> file" . $file . "<br />";  

$query = "update $table set `lock` = 0 where `id_r` = '{$_GP['mysqlId']}'";

// echo $query;

$result = mysql_query($query) or die("Invalid query: " . mysql_error());
//echo "Yra" . mysql_affected_rows ( );

//$content .= "<script>window.location = '$index?';</script>";


return $content;


?>

OPERATION 2
Set record as confirmed:
<?php

error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED );

$table = "t_form";

###############################
#                             #
#         PAREMTERS           #
#                             #
###############################
   
    $query = "update $table set `lock` = 0 where `id_r` = '{$_GP['mysqlId']}'";
    
    // echo $query;
    
    $result = mysql_query($query) or die("Invalid query: " . mysql_error()); 
    //echo "Yra" . mysql_affected_rows ( );

    return $content; 
    

?>


Generated an html, pdf invoice and sent email:
<?php

global $folder;

$query = "select id_r from $table where `lock` = '0'";
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

$count = mysql_num_rows($result) + 1;

$query = "select * from $table where `id_r` = '{$_GP['mysqlId']}'";
// echo $query; 
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

extract($row);

switch ($earlyRegistration) {
    
    case 50:
        $earlyRegistrationText = "Fifty, 00 EUR";
        
        break;
    
    case 70:
        $earlyRegistrationText = "Seventy, 00 EUR";
        
        break;
    
    case 90:
        $earlyRegistrationText = "Ninety, 00 EUR";
        
        break;
    
    case 120:
        $earlyRegistrationText = "One hundred twenty, 00 EUR";
        
        break;
        
}

$style = "
<style>

.tableWhite {

  border-color: white; 
  border-style: none; 
  width: 90%;
  
}

.tdBlack  { 

width: 50%;
border-top-color: black; 
border-top-style: solid;
border-width: 1px;

}

.tableWhite { 

border-color: white; 
border-style: solid; 
border-width: 1px;
width: 80%;

}

.tableBlack td { 

border-color: black; 
border-style: solid; 
border-width: 1px;

}

</style>";

$content = "

<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">
<tr>
<td align=\"center\"><img src = \"http://conf.kolegija.lt/_files/kolegija002.jpg\" /></td>
</tr>
<tr>
  <td align=\"center\">VILNIUS BUSINESS COLLEGE </td>
</tr>
<tr>
  <td align=\"center\">&nbsp;</td>
</tr>
<tr>
  <td align=\"center\"><font size=\"5\">INVOICE</font></td>
</tr>
<tr>
  <td align=\"center\">Series <b>IIT-2013 No. " . sprintf("%03d", $count) . "</b></td>
</tr>
<tr>
  <td align=\"center\"><b>" . date("Y-m-d") . "</b></td>
</tr>
<tr>
  <td align=\"center\">&nbsp;</td>
</tr>
<tr>
  <td align=\"center\">
  
          <table class = \"tableWhite\" align=\"center\" cellspacing = \"1\" >
        <tr>
          <td><strong>Seller:</strong></td>
          <td><strong>Buyer:</strong></td></tr>
        <tr>
          <td>VSI Vilniaus verslo kolegija</td><td>$titlename</td></tr>
        <tr>
          <td class = \"tdBlack\"><font size=\"2\">(Name)</font></td><td class = \"tdBlack\" ><font size=\"2\">(Name)</font></td></tr>
        <tr>
          <td>Kalvariju g. 125, LT-08221, Vilnius, Lithuania</td><td>$address</td></tr>
        <tr>
          <td class = \"tdBlack\"><font size=\"2\">(Address)</font></td><td class = \"tdBlack\" ><font size=\"2\">(Address)</font></td></tr>
        <tr><td>191807983</td><td>&nbsp;</td></tr>
        <tr>
          <td class = \"tdBlack\"><font size=\"2\">(Company code)</font></td><td class = \"tdBlack\">(VAT code)</td></tr>
        <tr><td >LT397300010002431920</td><td>&nbsp;</td></tr>
        <tr>
          <td class = \"tdBlack\"><font size=\"2\">(Bank account number/IBAN)</font></td><td>&nbsp;</td></tr>
        <tr><td>&quot;Swedbank&quot; AB, Konstitucijos pr. 20A, Vilnius, Lithuania</td><td>&nbsp;</td></tr>
        <tr>
          <td class = \"tdBlack\" ><font size=\"2\">(Bank name, address)</font></td><td>&nbsp;</td></tr>
        <tr><td>HABALT22</td><td>&nbsp;</td></tr>
        <tr>
          <td class = \"tdBlack\" ><font size=\"2\">(Bank/SWIFT code)</font></td><td>&nbsp;</td></tr>
        <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
        <tr><td>Company is registered inthe <br>
          State Enterprise Centre of Registers<br>
          Vilnius Department, register No. 076630 <br></td><td>&nbsp;</td></tr>
        </table>&nbsp;<br />
  
  </td>
</tr>
<tr>
  <td align=\"center\"  >
  <table  class = \"tableBlack\" cellspacing=\"0\" cellpadding=\"0\" >
    <tr>
      <td width=\"41\">&nbsp;&nbsp;No.</td>
      <td width=\"370\">&nbsp;&nbsp;Name</td>
      <td width=\"79\">&nbsp;&nbsp;Measure</td>
      <td width=\"64\">&nbsp;&nbsp;Amount</td>
      <td width=\"270\">&nbsp;&nbsp;Price, EUR</td>
      </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      </tr>
    <tr>
      <td>1</td>
      <td>$titlename</td>
      <td>1</td>
      <td>1</td>
      <td>$earlyRegistration</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr class = \"tdWhite\" >
      <td style = \"border-color: white\" >&nbsp;</td>
      <td style = \"border-color: white\" >&nbsp;</td>
      <td style = \"border-color: white\" >&nbsp;</td>
      <td style = \"border-color: white\" >&nbsp;</td>
      <td>Total: $earlyRegistration</td>
    </tr>
    </table></td>
</tr>
<tr>
  <td align=\"center\">&nbsp;</td>
</tr>
<tr>
  <td align=\"left\">Amount in words: $earlyRegistrationText</td>
</tr>
<tr>
  <td align=\"left\">&nbsp;</td>
</tr>
<tr>
  <td align=\"left\">Payment (bank transfer):</td>
</tr>
<tr>
  <td align=\"left\">&nbsp;</td>
</tr>
<tr>
  <td align=\"left\">Invoiced by:</td>
</tr>
<tr>
  <td align=\"center\">(Name or the first letter of name, surname, signature and position</td>
</tr>
<tr>
  <td align=\"center\">&nbsp;</td>
</tr>
<tr>
  <td align=\"left\">Invoice received:</td>
</tr>
<tr>
  <td align=\"center\">(Position, name, surname, signature)</td>
</tr>
<tr>
  <td align=\"left\">&nbsp;</td>
</tr>
</table>";

$filePdf = "$folder/$id_r/invoice.pdf";


print $style . $content . "Invoice link <a href = \"http://conf.kolegija.lt/_files/registrationForm/$id_r/invoice.pdf\" >http://conf.kolegija.lt/_files/registrationForm/$id_r/invoice.pdf </a> was send to email $email";

#############################
#                           #
#  Cool class, recommended  #
#                           #
#############################

include("mpdf/mpdf.php");


$contentMod = "<!DOCTYPE html>
<html><head><title>Print Invoice</title>
$style
</head>
<body>$content</body>
</html>";

//echo $filePdf;
$mpdf = new mPDF();

$mpdf->WriteHTML($contentMod);
$mpdf->Output("$filePdf", 'F');

$contentShort = "
6th annual international conference INNOVATIVE INFOTECHNOLOGIES 
FOR SCIENCE, BUSINESS AND EDUCATION, IIT . 2013 (Vilnius, November 14-16, 2013)

Invoice link: 

<a href = \"http://conf.kolegija.lt/_files/registrationForm/$id_r/invoice.pdf\" >http://conf.kolegija.lt/_files/registrationForm/$id_r/invoice.pdf </a> ";

mail("$email", "$contentShort", "Vilnius Bussiness College - Invoice");

?>

  
Previous articlePage topNext article  ALL TOPICS


Guest:
Hi

Hardcoded example :)


2013-06-07 11:13:21

 Use username: Guest, Anonymous, Programmer






QUOTES:
When you are sorrowful look again in your heart, and you shall see that in truth you are weeping for that which has been your delight.
Kahlil Gibran
The weakness of an enemy forms part of our own strength.
Saying
Talk well of your friends and of your enemies say nothing.
Proverb