Labels

Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, June 17, 2013

How to Create a simple login system with php + mysql script

This tutorial, We Learn to create a simple login system with php + mysql, this tutorial is easy to follow and teach you step by step.

Overview
In this tutorial, we create 3 php files for testing our code.
1. index.php (Main Login)
2. db_connect.php (for db connection)
3. Success.php

Steps
1. Create table "user_info" in database "company_name".
2. Create file index.php (Main Login).
3. Create file db_connect.php.
4. Create file success.php.
5. Create file logout.php


Friday, April 12, 2013

How to Creating Paging using PHP and MySQL

Its always possible that your SQL SELECT statement query may result into thousand of records.
But its is not good idea to display all the results on one page. So we can divide this result into many pages as per requirement.

Paging means showing your query result in multiple pages instead of just put them all in one long page.

<?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
   
    $db_selected = mysql_select_db("tweebd",$con);  // Database name tweebd
?>


Saturday, February 9, 2013

How to : Simple Mail in PHP; Contact From

Introduction
I will describe simple mail In PHP. For sending mail in PHP, I am using the mail() function. This function accepts five parameters. I have designed a simple contact mail form and sent mail from localhost. PHP e-mail code is used here. This code uses configuration settings in the php.ini file. With PHP you can create contact forms on your website. The mail() function is part of the PHP core.
Syntax
mail($to, $subject, $message, $headers);

Parameter Description
To  Indicates the Receiver.
Subject  Specific subject of the E-mail.
Message  Define the message to be send.
Headers  Additional headers like, From, Cc, and Bcc.


Example
<?php
if(isset($_POST["Submit"])){
$to = "studentvinod.87@gmail.com";
$subject = "Contact mail";
$from=$_POST["Email"];
$message=$_POST["Message"];
$headers = "$from"; mail($to,$subject,$message,$headers);
echo "Email successfully sent.";
}
?>
<html>
<head>
</head>
<body>
<form name="form" method="post" action="" >
 <table bgcolor=#ffffcc align=center>
 <tr><td colspan=2><strong>Contact us using this form:</strong></td></tr>
 <tr><td><font color=red>*</font> Name:</td><td><input size=25 name="Name"></td></tr>
 <tr><td><font color=red>*</font> Email:</td><td><input size=25 name="Email"></td></tr>
   <tr><td colspan=2>Message:</td></tr>
 <tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35 id="message"></textarea></td></tr>
 <tr><td colspan=2 align=center><input name="Submit" type="submit" id="Submit" value="Submit" ></td></tr>
 </table>
 </form>
</body>
</html>
Ref. link 


--------------------------------------------------------------------------------------------------------------------------------
Search Keyword :
learn php, php tutorial, php examples, php scripts

Friday, January 25, 2013

PHP MySql Connect Code

You Can create a .php file with name db_connect.php and follow this code.
<?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
   
    $db_selected = mysql_select_db("twee_home",$con);
?>


NOW you can connect your index.php page with db_connect.php 
code below 

top on the page :
<?php
    require_once('db_connect.php');
    session_start();
   
    $
today = gmdate('D d-m-Y H:i:s', strtotime('+6 hours'));  // server today's date, time,
?>


Changes :
"localhost", "root","" = hostname, username, password // IF your mysql password set already

twee_home = database name ,

Thursday, December 20, 2012

How to count mysql rows


<?php
 

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);
 

echo "$num_rows Rows\n";
 

?>