WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A Simple Script that stores encrypted messages in databases
Categories : PHP, Databases, MySQL, Security Click here to Update Your Picture
Vivek Ramnath
Date : Aug 07th 2004
Grade : 4 of 5 (graded 3 times)
Viewed : 9124
File : 3970.zip
Images : No Images for this code example.
Search : More code by Vivek Ramnath
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<!--
This script encrypts and stores the message in the encrypted form in the database.
This can also be implemented as a function.
Be sure to Change the queries according to the fields in ur databse. But itz mandatory to include
the ivec field which is the ini vector for the encryption algorithm.

The backend CREATE is as follows:
CREATE TABLE `messenc` (
  `uid` text NOT NULL,
  `dom` text NOT NULL,
  `ext` text NOT NULL,
  `encmess` longtext NOT NULL,
  `ekey` text NOT NULL,
  `iv` varchar(100) NOT NULL default '',
) TYPE=InnoDB;


Variable Docs:
$ekey is the encryption key given by user
$to - Is the mail id ex:veevakan

Anybody having problems with this script can mail me with the correct error message.
Put the subject line as "MessEncrypt :Bug Mail "
My @ is : veevakan@email.com
The class implementation for all the databases is on itz way

<HTML>
<TITLE>
Text Encrypted
</title>
<body  text="Lucida Console" size="4">
<?
$key
=$ekey;
$add=$to;
$domai=$dom;
$exte=$ext;
$ciph=$cipher;
print(
$ciph);//DEBUG LINE
$iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB), MCRYPT_RAND);// gets the initialization vector for MCRYPT_RIJNDAEL_256 algorithm .for more algorithms look refer the PHP Manual.
$cryptext=mcrypt_encrypt (MCRYPT_RIJNDAEL_256,$key, $ta1, MCRYPT_MODE_ECB, $iv); //The message is encrypted here

$connect=mysql_connect("127.0.0.1", "uname","mysqlpassword");
mysql_select_db("user_reg");  //This is the database which contains the messenc table
if($connect!=0)
  {
   
$query="SELECT encmess FROM messenc WHERE uid='$add' and dom='$domai' and ext='$exte' and  ekey='$key'";
 
$res = mysql_query($query); //Checks whether the message  already exists in the table

   
if($res)
        {
     
$row=mysql_fetch_assoc($res);
        if(
mysql_num_rows($res)>0)
           {
       
$ecmess=$row["encmess"]
         if(
strcmp($ecmess,$cryptext)!=0) // Checks the message from table and the encrypted message
             
{
   
$query1="INSERT INTO messenc(uid,dom,ext,encmess,ekey,ivec)"." VALUES('$add','$domai','$exte',"."'$cryptext','$key','$iv')"; // If the message is new ,then inserted into table
   
$quok=mysql_query($query1);
        if(
$quok!=false)
          {   
        print(
"<BR><BR>   Done");
        print(
$iv);
         } 
    else
        {
        print(
"Error during DB operations");
          }
    }
    else
        {
        print(
"<BR><B>Message11 already inserted</b><BR>"); //DEBUG LINE
       
}
     }

else
{
    print(
"<BR><B>Message12 already inserted</b><BR>");//DEBUG LINE
}
    }
   
 
  else
      {
print(
"Couldn't connect to DSN1");
      }
  }
?>

</body>
</html>



A login page that require username, password and userlevel.
Categories : PHP, Security, Sessions, MySQL, Databases
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
GroupIT Engine v1.00rc1
Categories : PHP, Content Management, MySQL, Databases
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
free, search engine, indexing, system, information, web, ftp, http, free, software, cgi, php, MySQL, database, php3, FreeBSD, Linux, Unix, UdmSearch
Categories : MySQL, Complete Programs, PHP, Databases, Search
Invision Forums Latest Threads list
Categories : PHP, Miscellaneous, Databases, MySQL
Required form fields that pull from MySQL database
Categories : PHP, HTML and PHP, Databases, MySQL
Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, Databases, MySQL
AJAX Application
Categories : PHP, AJAX, Databases, MySQL
color codes for positive and negative numbers
Categories : PHP, MySQL, Databases, HTML
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
Function to do live population of HTML's <Select> tag from a Table
Categories : PHP, MySQL, HTML and PHP, Databases