Saturday, 21 September 2013

Create RSS Feed with PHP Mysql

RSS feed is playing main role for syndicating information to large audiences. By this feed you can update your audience with your latest content or information. RSS feed means that if you have some number of registered audiences then you can share your new updates and news directly to your audience on their registered e-mails ID.
In this tutorial I will explain how to populate your database content to RSS feed. Here in RSS feed we will display some useful content like title, description, date and image etc. For this we will use PHP and mysql to populate content for RSS feed. Here we will retrieve this content from database and format these content into RSS format.
Steps are given below: Create table for getting data for RSS Feed
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE IF NOT EXISTS `table_rss` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` text NOT NULL,
  `description` text NOT NULL,
  `url` text NOT NULL,
  `image` varchar(255) NOT NULL,
  `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `status` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=35 ;
Create a php like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!--?php
define ("DB_HOST", "localhost"); // set database host
define ("DB_USER", ""); // set database user
define ("DB_PASS",""); // set database password
define ("DB_NAME",""); // set database name
  
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
$query = "SELECT title, description, image, url FROM ".table_rss." WHERE status=1 ORDER BY created_date desc";
$getBlogDisplay = mysql_query($query);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?-->
<rss version="2.0">
<channel>
<title></title>
<link>
<description></description>
<language>en-us</language>";
while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){
           
 $title         = $dataBlogDisplay['title'];
 $link          = $dataBlogDisplay['url'];
$description    = $dataBlogDisplay['image'];
echo "<item>
<title>$title</title>
<link>http://www.discussdesk.com/$link.htm
<description>$description</description>
</item>";
}
echo "</channel></rss>";
?>
That's all about RSS Feed. Just download and start feeding your content.
Read More : http://www.discussdesk.com/create-rss-feed-with-php-mysql.htm

Thursday, 19 September 2013

Create Registration Form using PHP and Mysql

In this tutorial, I will explain that how to create a simple registration form in PHP and mysql. Registration form is necessary for all online activities for small website to a big web portal. Registration means providing necessary information to the website for further activities. The website will store all the information into their database and when you will again visit that website you just need to login no need to provide detail again.



So the registration form has important role in present website.
Here, we are using javascript validations for input fields. So user can learn different type of validation in javascript like simple text field, email ID etc.

Now we will see how to create Registration Form in PHP and Mysql step by step.
Steps are given below:
There are four files for Registration Form:
  1. dbConfig.php
  2. register.php
  3. registerAction.php
  4. validate.js
The dbConfig.php file looks like this:
1
2
3
4
5
6
7
8
9
<!--?php
define ("DB_HOST", "localhost"); // set database host
define ("DB_USER", ""); // set database user
define ("DB_PASS",""); // set database password
define ("DB_NAME",""); // set database name
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
?-->
Here just change the above value like Host name, database user name, database password and database name.
The register.php file looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
<form action="registerAction.php" method="post" name="frmregister">
<table class="form" border="0">
    <tbody>
        <tr>
            <th><strong>Name:</strong></th>
            <td><input name="name" size="30" type="text"></td>
        </tr>
        <tr>
            <th><strong>Nick Name:</strong></th>
            <td><input name="nick_name" size="30" type="text"></td>
        </tr>
        <tr>
            <th><strong>Email:</strong></th>
            <td><input name="email" size="30" type="text"></td>
        </tr>
        <tr>
            <th><strong>Password:</strong></th>
            <td><input name="password" size="30" type="password"></td>
        </tr>
        <tr>
            <td> </td>
            <td><input alt="Submit" value="Submit" type="submit"> <input alt="Reset" value="Reset" type="reset"></td>
        </tr>
    </tbody>
</table>
</form>
The registerAction.php file looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!--?php
include "dbConfig.php";
if($_POST[ 'name' ]!="") {
$name = mysql_real_escape_string($_POST["name"]);
$nick_name = mysql_real_escape_string($_POST["nick_name"]);
$email = mysql_real_escape_string($_POST["email"]);
$password = mysql_real_escape_string($_POST["password"]);
$sql = "insert into members set name='".$name."', nick_name='".$nick_name."', email='".$email."', password='".md5($password)."' ";
$sql = mysql_query($sql);
$msg = '
<p class = "tanx"-->Thank you for completing your online registration form!.';
}else{
$msg = "Your enquiry sending failed";
}  
?>
That’s all about Registration Form.

See more at: Click Here

Friday, 6 September 2013

Download Login Form in PHP and Mysql


In this tutorial I will explain that how to create a login form in PHP mysql. Creating login form in any language has same concept that We will retrieve the previously stored User credential like User name and password and while Login when user provide inputs like Username and password, we will compare this Input with the stored fields for that User. When both are same user will redirect to the next page otherwise some error will print with login fail message. Now let us understand the steps behind this

Steps for creating a Login Form are given below:
There are two PHP file
  1. dbConfig.php
  2. login.php
The dbConfig.php file looks like this:
1
2
3
4
5
6
7
8
9
<!--?php
define ("DB_HOST", "localhost"); // set database host
define ("DB_USER", ""); // set database user
define ("DB_PASS",""); // set database password
define ("DB_NAME",""); // set database name
 
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
?-->
Here just change the above value like Host name, database user name, database password and database name.
The login.php file looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--php include "dbConfig.php";
$msg = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $name = $_POST["name"];
    $password = md5($_POST["password"]);
     if ($name == '' || $password == '') {
        $msg = "You must enter all fields";
    } else {
        $sql = "SELECT * FROM members WHERE name = '$name' AND password = '$password'";
        $query = mysql_query($sql);
 
        if ($query === false) {
            echo "Could not successfully run query ($sql) from DB: " . mysql_error();
            exit;
        }
 
        if (mysql_num_rows($query) --------> 0) {
          
            header('Location: YOUR_LOCATION');
            exit;
        }
 
        $msg = "Username and password do not match";
    }
}
?>
In this file just change YOUR_LOCATION variable into your exact success path.
That's all... Enjoy with login form
For any feedback and comment, Please write us below comment. Your comment will be highly appreciable.



: