WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
Web Development Resources
Web Development Content
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
Mobile Dev World

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 : 7908
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 
 

<!--
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
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT
Categories : PHP, MySQL, Java Script, Databases
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
MySQL database class
Categories : PHP, MySQL, Databases, PHP Classes
List people whose birthdays fall on the current Day and Month
Categories : Databases, Date Time, MySQL, PHP
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
A Simple sign up script with PHP and JavaScript validations.
Categories : PHP, Java Script, MySQL, Databases
Point and Click Interface ala MS Access for creating SQL statements.
Categories : MySQL, Complete Programs, General SQL, PHP, Databases
phpEasySQL - Easily connect to your MySQL database with just 1 php file and 3 easy steps!
Categories : Databases, PHP, MySQL, General SQL
Simple db results paging example
Categories : PHP, MySQL, Databases, Form Processing
Invision Forums Latest Threads list
Categories : PHP, Miscellaneous, Databases, MySQL
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides