Php code and Programming Concepts :
The php.ini ,the php Configuration file
There are two examples of PHP configuration files that come with PHP when you download it: php.ini-dist and php.ini-recommended. After you download and install PHP,there will be one file named php.ini strategically placed on your system,and each time PHP starts it will read this file and set itself up accordingly. The php.ini file can be written out by hand.
 
Setting up Apache for PHP

To install Apache ,use RPMs or download and compile the source code .But Apache probably comes with your Linux(The open source leader) distribution,and may already be properly installed .On my Red Hat Fedora installation Apache was already installed, and that was needed to verify this ,go to the Red Hat Button System Settings -->Server Settings --> Services and look for httpd.

If apache is not already installed and running ,you can use these commands for installing itfrom the Terminal:
lynx http://httpd.apache.org/download.cgi
gzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0.NN.tar
/configure --prefix =PREFIX
Make
Make instal
vi PREFIX/conf/httpd.conf
PREFIX/bin/apachect1 start
 
 
   
       
   
User Login and Password Code

<?php
include "header.php";
include "admin/connect.php";
if (isset($_POST['submit']))
{
$login=$_POST['login'];
$password=$_POST['password'];
print "$login";
$LoginPass = md5($password);
$getUid = "Select * from registration where UserId='$login' and Password ='$password' ";
$execQuery = mysql_query($getUid) or die("Could not found data");
$execQuery1 = mysql_fetch_array($execQuery);
if($execQuery1)
{

$_SESSION['login']=$login;

// print "Login Successful please go to <A href='index.php'>Admin Panel</a>";
print "Redirecting <META HTTP-EQUIV = 'Refresh' Content = '2; URL =postmessage.php'> ";
}
else
{
print "Could not login ";
}

}
?>

 
 
 
Client side Validation in PHP
function check_fname($var1){
if(!preg_match("/[^0-9\.\-\ß\ä\Ä\ü\Ü\ö\Ö\ ]+$/",$var1)) return TRUE;
else return FALSE;
}
function check_Lname($var2){
if(!preg_match("/[^0-9\.\-\ß\ä\Ä\ü\Ü\ö\Ö\ ]+$/",$var2)) return TRUE;
else return FALSE;
}
function check_phone($var3){
if(!preg_match("/[^0-9\ ]+$/",$var3)) return TRUE;
else return FALSE;
}
function check_Fax($var4){
if(!preg_match("/[^0-9\ ]+$/",$var4)) return TRUE;
else return FALSE;
}

function check_Mobile($var5){
if(!preg_match("/[^0-9\ ]+$/",$var5)) return TRUE;
else return FALSE;
}
function check_zipcode($var6){
if(!preg_match("/[^0-9\ ]+$/",$var6)) return TRUE;
else return FALSE;
}
function check_email($var7){
if(!preg_match("/.*@.*\..*/",$var7)) return TRUE;
else return FALSE;
}

 
 
Inserting the data in My Sql table using PHP
<?php
include "admin/connect.php";
//$Message = $_POST['Message'];
//$Subject = $_POST['Subject'];
if (isset($_POST['submit']))
{
if (!$_POST['Message'])
{
print "Enter the message";
}
else if (!$_POST['Subject'])
{
print "Enter the Subject";
}
else
{
$Subject =$_POST['Subject'];
$Message =$_POST['Message'];
$insertmessage ="Insert into message(Subject,Author,DatePosted,IsActive,Description) values
('$Subject','Adnan','13/03/2006','1','$Message')";
mysql_query($insertmessage) or die("Please insert Correct Information");
print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =forum.php'> ";
}
}

?>

 
Connection String in php
<?php
$db=mysql_connect("localhost","root","password") or die("Could not find the host");

if (!$db)
die("no database available");
if (!mysql_select_db("dbname",$db))
die("No Database selected");

?>

 
   
         
 
© Copyrights ideallogics.com. all rights reserved.