Welcome to Onlinetunes24 .....

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 1 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 2 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 3 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 4 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

PHP-MySQL Connection



File Name: Configuration.php
<?php
            $host = 'localhost'; // Local host name
            $username = 'root'; // Local host username
            $password = ''; // Local host password
            $database = 'xxxxx’; // Database name

       $connection = mysql_connect ($host, $username, $password) or die ('MySQL database connection error !!');
        mysql_select_db ($database, $connection) or die (MySQL database selection error !!');
?>

Create a Database using PHP Script



File name: create_database.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                        <title>Database Create</title>
            </head>
<body>
            <div align="center">
                        <h1> Database Information </h1>
                        <form action="create_database.php" method="post" name="db"> <br  />
                                    <input name="host" type="text" value="localhost" /> <br  />
                                    <input name="user" type="text" value="root" /> <br  />
                                    <input name="pass" type="password" value="" /> <br  />
                                    <input name="db" type="text" value="" /> <br  /><br  />
                                    <input name="submit" type="submit" value="Create Database" /> <br  />
                         </form>
            </div>
</body>
</html>
<?php
$dbhost=$_REQUEST['host'];
$dbusername=$_REQUEST['user'];
$dbuserpass=$_REQUEST['pass'];
$dbname=$_REQUEST['db'];
if($dbhost!="" && $dbusername!="" && $dbname!="") {
$con = mysql_connect ($dbhost, $dbusername, $dbuserpass) or mysql_error();
if (!mysql_query("CREATE DATABASE $dbname")) die(mysql_error());
mysql_select_db("$dbname");
            $info = "CREATE TABLE info (
            id int(11) NOT NULL auto_increment,
            name varchar(255) NOT NULL,
            address varchar(255),
            cell varchar(255),
            PRIMARY KEY(id) )";
        $results = mysql_query($info) or die (mysql_error());
        echo "Database create successfully !!";
 }
        else 
           echo "Dose not empty any field !!";
?>  

PHP Mail Function



File Name: mail_test.php
<form name="email" method="post" action=”mailscript.php”>
<p>Name : <input type="text" name="name" /></p>
<p>E-mail :<input type="text" name="email" /></p>
<p>Subject :<input type="text" name="subject" /></p>
<p>Message : <textarea name="message" cols="25" rows="5"></textarea></p>
<p><input type="reset" name="reset" value="Reset" /> || <input name="submit" type="submit" value="Submit" /> </p>
</form>   

File Name: mailscript.php 
<?php
            $name=$_POST['name'];
            $email=$_POST['email'];
            $subject=$_POST['subject'];
            $message=$_POST['message'];
           
            if($name!="" && $subject!="" && $message!="") {
                        if($email!="") {
                                    if(preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})+$/",$email)) {
                                    $to = "engr.lukman@gmail.com";/* Reciptionist email */
                                    $where = "Email received from Choukosh ";
                                    echo "<h2>Email Delivery Report:</h2>";
                                    echo "<h3>Thank You - $name</h3>";
                                    echo mail($to,$where,"Name : $name\r\nSubject : $subject\r\n Message : $message","From:$email");
                                    echo "<h4>As soon as possible communicate to you !</h4>";
                                    }
                                    Else {
                                                echo "<h1 align=\"center\" style=\"color:red\">Valid email enter please !!</h1>";
                                    }
                        }
                        else {
                                    echo "<h1 align=\"center\" style=\"color:red\">Email should not empty please !!</h1>";
                        }
            }
            else {
                                    echo "<h1 align=\"center\" style=\"color:red\">Mail not send successfully !</h1>";
            }
?>

Functions



PHP Functions:

·         PHP Built-in Functions

·         User Define Function

 

Create a PHP Function: A function will be executed by a call to the function.

 

Example: A simple function that writes my name when it is called:

<?php
          function writeName(){
echo "Kai Jim Refsnes";
}
echo "My name is ";
writeName();
?>

PHP Forms and User Input: The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.

 

PHP Include Files: Assume that you have a standard header file, called "header.php". To include the header file in a page, use include/require:

<?php include 'header.php'; ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle