Thursday, 17 October 2013

WordPress - The CMS

WordPress Definition 
                      WordPress is a Content Management System based on PHP and MySQL.WordPress is very popular CMS and it is easy to learn and use this CMS compare to any other CMS. It is an Open source Project made by community and there were thousands of developer around the world handle it.
                    
Features of WordPress 
                      1) WordPress Provides more than 2 thousands of Themes today and it's growing.With the help of theme we can change the look of the website with only one click.
                      2) It provides more than 27 thousands of Plugins for making different websites from others to give varieties of techniques and functions to the website.
                      3) There were plenty of websites available which are built with the help of this CMS. Today there were millions of websites are there which were made using WordPress.
                      4) Menu management is very easy and we can arrange any numbers of menu items into menu of our website using WordPress.
                      5) We have to just write our content the management will be done by automatically in the CMS.
                       6)Every day new plugins or update of older plugins is available to and it's most of them are for free.And that's the reason for people or developer around the world are using WordPress.
                       7) We can also get supported by active community members of the WordPress.org

                     

Learn CMS Training with PHP Project Training
Visit Website : CMS Training Institute

                   
                     

Tuesday, 24 September 2013

What is CMS or Content Management System ?

Introduction to CMS
                           CMS is Content Management System used to create Website. It is the Technology in the world of Web. CMS is very useful tool for creating User Friendly, Interactive, Innovative Websites. We can easily learn CMS and create websites within sort time. If you are programmer or not You can Easily create an eye catchy website with the help of Content Management System.
                           If you are creating a website that have to more than ten pages you have probably run into the problems associated with adding new pages, or groups of new pages into the website. It becomes difficult to add to the menu of every existing page. A Content Management System handles the Menu's, And navigational aids for you. CMS free you to concentrate on your writing for your website. 
                          Several Popular CMS in the world are :
                          1. Wordpress
                          2. Joomla
                          3. Drupal
                          4. Modx
                          5. TinyCMS , etc.

Advantages of CMS : 
                        1. CMS is very useful for creating article or webpage content and we can easily modify or delete the content of the webpage. 
                         2. The template of the website also managed well.Using only a single click we can change the layout or template of the whole website.
                         3. We can also add lots of addon or modules into the CMS which are already created by the group of contributors or professionals. 
                          4. Menu management is also there and we can position our menu to different location on the webpage.
                           

                           
                            
Learn PHP CMS visit website : Click Here

   


Tuesday, 21 May 2013

What is Apache Web Server ???


Originally Developed at National Center for Supercomputing Applications in 1994 .
It is Open Source And The First project / product of the Apache Foundation.

Brian Behlendorf founded Apache .
Now it is used with Php and Mysql.

Friday, 3 May 2013

MyAccount- Change Password using PHP and MySQL code

Change Password Using PHP and MySQL.

If user wants to change their password then put update query of MySQL using PHP webpage scripting.

First Step to check weather user had input their old password, new password and confirm new password.
If not then give error message using PHP script.

After that check database connection and write query to update oldpass with newpass.

Here is the full code to change your password using PHP  + MySQL.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> Change Password </title>
<?php
if(isset($_POST['submit']))
{
include('dbconn.php');
$old=trim($_POST['oldpass']);
$new=trim($_POST['newpass']);
$cnew=trim($_POST['cnewpass']);
if(empty($old))
{
echo "<p style='color:red;'> Please Enter Your Old Password </p>";
}
elseif(empty($new))
{
echo "<p style='color:red;'> Please Enter Desired New Password </p>";
}
elseif(empty($cnew))
{
echo "<p style='color:red;'> Please Enter Confirm New Password </p>";
}
elseif(strcmp($new,$cnew))
{
echo "<p style='color:red'> New Password And Confirm New Password Does Not Match </p>";
}
else
{
$sql="SELECT * FROM tbl_employer_reg WHERE password='$old'";
$result=mysqli_query($con,$sql);
$num_rows=mysqli_num_rows($result);
if($num_rows==1)
{
$sql="UPDATE `tbl_employer_reg` SET `password`= '$new' WHERE `password`= '$old'";
$r=mysqli_query($con,$sql);
echo "<p style='color:red;'> Your Password Has Been Changed</p>";

}
else
{
echo "<p style='color:red;'> Incorrect Password </p>";
}

}
$_POST['oldpass']="";
$_POST['newpass']="";
$_POST['cnewpass']="";
}
?>
</head>

<body>
<div style="width:520px;padding:10px;border:5px solid blue;margin:150px 250px;border-radius:25px;">
<h2 style="color:red"><center>  CHANGE PASSWORD </center></h2>
<form name="change_pass" id="change_pass" method="post" action="">
<table border="0" cellpadding="6">
<tr> 
<td style="color:#0000FF; font-weight:bolder; font-size:18px;">Enter Old Password : </td>
<td> <input type="password" name="oldpass" value="<?php if(isset($_POST['oldpass'])) {echo $_POST['oldpass'];} ?>"  size="40" /></td>
</tr>
<tr> 
<td style="color:#0000FF; font-weight:bolder; font-size:18px;">Enter New Password : </td>
<td> <input type="password" name="newpass" value="<?php if(isset($_POST['newpass'])) {echo $_POST['newpass'];} ?>" size="40" /></td>
</tr>
<tr> 
<td style="color:#0000FF; font-weight:bolder;font-size:18px;">Confirm New Password : </td>
<td> <input type="password" name="cnewpass" value="<?php if(isset($_POST['cnewpass'])){echo $_POST['cnewpass'];} ?>" size="40" /></td>
</tr>
<tr>
<td> </td>
<td> <input type="submit" name="submit" value="SUBMIT" style="color:#0033FF;background-color:#CCCCCC; font-weight:bolder;font-size:22px"  /> </td>
</tr>
</table>

</form>
</div>

</body>

</html>

Learn PHP Project Training 
visit website: Project Training Using PHP Technologies

Forgot Password Code for PHP + MySQL

Forgot Password PHP Language code.

If any user forgot their password then you can send them email or
To give them password on the same web page.
Here is the code which shows the password if user forgot it. Enter Username and Mobile no to show the password.


<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Forgot Password </title>
<?php
if(isset($_POST['submit']))
{
include('myconnection.php');
$un=trim($_POST['username']);
$mn=trim($_POST['mobileno']);

if(empty($un))
{
echo "<p style='color:red;'> Please Enter Your UserName </p>";
}
elseif(empty($mn))
{
echo "<p style='color:red;'> Please Enter Your Mobileno </p>";
}
else
{
$sql="select `password` from tbl_employer_reg where `emailid`='$un' and `mobile`='$mn'";
$result=mysqli_query($con,$sql);
$num_rows=mysqli_num_rows($result);
if($num_rows==1)
{
while($line=mysqli_fetch_array($result))
{
echo "your Password is ".$line['password'];
}
}
else
{
echo "Invalid Username/Mobileno";
}
}
}
?>
</head>

<body>

<h2 style="color:red"><center>  FORGOT PASSWORD </center></h2>
<form name="form"  method="post" action="">
<table border="0" >
<tr>
<td >Enter Your Username: </td>
<td> <input type="text" name="username" value=""  size="40" /></td>
</tr>
<tr>
<td >Enter your mobile no : </td>
<td> <input type="text" name="mobileno" value="" size="40" /></td>
</tr>
<tr>
<td> </td>
<td> <input type="submit" name="submit" value="SUBMIT"   /> </td>
</tr>
</table>

</form>
</div>
</body>
</html>

Thursday, 2 May 2013

Delete record using php + MySQL

Delete Record Using PHP + MySQL.

If Any web programmer of Web Developer doing code for delete any record from the table then
1. He/She must have to see all the records of the table
2. And select the record to delete and press on delete button.
3. After deleting the record he/she must have to see the records of the table.

Here is the full code to see the records from the table and search the user according to the username.
If records are not more then see all the records by search with empty textbox and click on SUBMIT button.
After Search Result is generated Press on Delete.


Table Name of MySQL is tblreg
Have columns
1. id
2. username
3. hobbies
4. gender
5. emailid
6. mobileno

1. showreg.php file code


<?php
if(isset($_GET['submit']))
{
$s=trim($_GET['search']);
$con=mysqli_connect(@"localhost","root","","phpdemo") or die("Unable to connect to the database of Mysql name :  phpdemo");
if(empty($s))
{
$sql="select * from tblreg";
}
else
{
$sql="select * from tblreg where username='$s'";
}
echo "<center>";
echo "<h1 style=\"color:Yellow;background-color:Black \">Show Registration Details</h1>";
$result=mysqli_query($con,$sql);
echo "<table border=\"2\" style=\"color:Black;background-color:#ffffcc\">";
echo "<th>Userid</th><th>Username</th><th>Hobbies</th><th>Gender</th><th>Emailid</th><th>Mobileno</th>";
while($line= mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo $line['id'];
echo "</td>";
echo "<td>";
echo $line['username'];
echo "</td>";
echo "<td>";
echo $line['hobbies'];
echo "</td>";
echo "<td>";
echo $line['gender'];
echo "</td>";
echo "<td>";
echo $line['emailid'];
echo "</td>";
echo "<td>";
echo $line['mobileno'];
?>
<input type="text" name="chid" value="<?php echo $line['id']; ?>" />
<?php
echo "</td>";

echo '<td><b><font color="#663300"><a href="delete.php?id=' . $line['id'] . '">Delete</a></font></b></td>';
echo "</tr>";

}
echo "</table>";

}
?>
<body>
<form id="showform" name="showform" method="get" action="">
<input type="text" name="search" />
<input type="submit" name="submit" value="submit" />
</form>



To Delete Record of The User write code on delete.php File.2.  delete.php After Deleting the record he/she must reach at showreg.php to see the records of the table tblreg.






<?php
$con=mysqli_connect(@"localhost","root","","phpdemo") or die("Unable to connect to the database of Mysql name :  phpdemo");
$id = $_REQUEST['id'];
echo "id is $id<br>";
$sql="DELETE FROM `tblreg` WHERE `id`='$id'";
$result = mysqli_query($con,$sql) or die("Error in Deleting!!!");
header("Location: showreg.php");
?>

PHP code to send email

after hosting is done for your website.
you can send email by using the below code of mail function in PHP


<?php
if(isset($_POST['submit']))
{
$errors = '';

if(empty($_POST['name'])  ||
   empty($_POST['toemail'])||
   empty($_POST['subject']) ||
   empty($_POST['email']) ||
   empty($_POST['message']))
{
    $errors .= "\n Error: all fields are required";
}
$myemail = $_POST['toemail'];//<-----Put Your email address here.
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
    $errors .= "<br> Error: Invalid email address";
}

if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n\n Name: $name \n\n Subject: $subject \n\n Email: $email_address \n\n Message \n\n $message";

$headers = "From: $email_address\n";
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
echo "<center><p style=\"color:Green\"> Thank you !!! We will come to you shortly</p></center>";
}
else
{
echo "<center><p style=\"color:Red\">".$errors."</p></center>";
}
}
?>
<html>
<head>
<title>Send email using php</title>
</head>
<body>
<form id="form" name="form" method="post" action="">
<center>
<table>
<tr><td>Enter emailid for To : </td><td><input type="text" name="toemail" /></tr>
<tr><td>Enter your Name : </td><td><input type="text" name="name" /></tr>
<tr><td>Enter your Email : </td><td><input type="text" name="email" /></tr>
<tr><td>Enter your Subject : </td><td><input type="text" name="subject" /></tr>
<tr><td>Enter your Message : </td><td><input type="text" name="message" /></tr>
<tr><td></td><td>
<input type="submit" name="submit" value="submit" /></tr>
</table>
</center>
</form>
</body>
</html>


Tuesday, 23 April 2013

How to Add New State into the database of PHP + MySQL ???

For Add new state countries must fill from the database table of the country.
To add state information according to the selected country using PHP and MySQL, here's the process in simple terms:

Database Setup:

Create two tables: one for countries and one for states.
The countries table holds the list of countries.
The states table stores the states along with a reference (foreign key) to the country they belong to.
Insert Data:

Add some sample countries like "USA", "India", and "Canada" in the countries table.
Add related states like "California" and "New York" for the USA, and "Maharashtra" and "Gujarat" for India in the states table, with a link to the respective country.
User Interface:

Display a country dropdown in an HTML form.
When the user selects a country from this dropdown, an AJAX request is sent to the server to retrieve the corresponding states for that country.
Server-Side Processing:

On the server-side (PHP), receive the selected country ID from the AJAX request.
Query the states table in the database to fetch the states related to the chosen country.
Send back the list of states as options to be displayed in a second dropdown (the states dropdown).
User Experience:

The user first selects a country, and the states dropdown automatically updates with the relevant states.
This is done without needing to refresh the page, creating a smooth and dynamic experience.
In summary, the process involves linking states to countries in the database, dynamically fetching states based on the selected country using PHP, and updating the UI with the state data via AJAX.


Here is one example of it


<html>
<head>

<title>Title of Page</title>
<script language="javascript" type="text/javascript">
function showState(countryid)
{
 document.form1.submit();
}
</script>
<?php
include('myconnection.php');
if(isset($_POST['submit']))
{
$sname=trim($_POST['statename']); 
$cid=trim($_POST['countryid']); 
if(empty($sname))
{
echo "<center><p style=\"color:Red\" >Please Enter State name</p><center>";
}
else
{ $sql="insert into tblstate(`id`,`countryid`,`statename`) values(NULL,'$cid','$sname');";
if(mysqli_query($con,$sql))
{
echo "<center><p style=\"background-color:#000;width:450px;color:#fdd000\" >Statename is successfully inserted !!!</p><center>";
}
else
{
echo "error".mysqli_error();
}
}
}
?>
</head>
<body>
<form id="form1" name="form1" method="POST"  action="">
<center><fieldset style="width:450px">
<legend ><h1 style="background-color:#000fdd;color:#ffff00">Add New State</h1></legend>
<table>
<tr><td colspan="2"></td></tr>
<tr>
<td>Select Country</td>
<td>
<?php
$query = "SELECT * FROM tblcountry";
$result = mysqli_query($con,$query);
?>
<select name="countryid" id="countryid"  onChange="showState(this.value);">
<option value="">--- Select Country---</option>

<?php
while ($line = mysqli_fetch_array($result)) {
?>

<option value="<?php echo $line['id'];?>" > <?php echo $line['countryname'];?> </option>

<?php
}
?>
</td></tr>
<tr><td>StateName</td><td><input type="text" name="statename" value="" /></td></tr>
<tr><td></td><td><input type="submit" name="submit" value="submit"><input type="reset" name="reset" value="reset">
</td>
</tr>
</table>
</fieldset>

</center>
</form>
</body>

</html>

Create foreign key in mysql

How to create Foreign Key in MySQL

create table tblstate
(
id int primary key auto_increment not null,
countryid int ,
statename varchar(20),
foreign key(countryid) references tblcountry(id)
)


OR


ALTER TABLE tblstate ADD CONSTRAINT countryid_ref FOREIGN KEY (countryid) REFERENCES tblcountry (id);

Monday, 22 April 2013

How to insert records in table using PHP + MySQL ???

HTML and PHP code to insert new record 

HTML page having radio button list and checkbox list

Copy and paste this code into the html body part


<form id="form1" name="form1" method="POST" action="">
<table>
<tr><td colspan="2"><h1>REGISTRATION FORM</h1></td></tr>
<tr><td>Username</td><td><input type="text" name="username" value="" /></td></tr>
<tr><td>password</td><td><input type="text" name="password" value="" /></td></tr>
<tr><td>confirm password</td><td><input type="text" name="repassword" value="" /></td></tr>
<tr><td>Hobbies</td><td><input type="checkbox" name="hobbies[]" value="cricket" />Cricket<input type="checkbox" name="hobbies[]" value="football" />FootBall<input type="checkbox" name="hobbies[]" value="carrom" />Carrom</td></tr>
<tr><td>Gender</td><td><input type="radio" name="gender[]" value="male" />MALE<input type="radio" name="gender[]" value="FEMALE" />FEMALE</td></tr>
<tr><td>Emailid</td><td><input type="text" name="emailid" value="" /></td></tr>
<tr><td>Mobileno</td><td><input type="text" name="mobileno" value="" /></td></tr>
<tr><td></td><td><input type="submit" name="submit" value="submit"><input type="reset" name="reset" value="reset">
</td>
</tr>
</table>
</form>


php code 


<?php
if(isset($_POST['submit']))
{$s="";
 $g="";
$user=trim($_POST['username']); 
$pass=trim($_POST['password']);
$email=trim($_POST['emailid']);
$mobile=trim($_POST['mobileno']);

if(!isset($_POST['hobbies'])) 
{
echo("<p>please select your hobbies</p>\n");

else 

$ho = $_POST['hobbies'];
for($i=0; $i<sizeof($ho); $i++)
{
$s .= $ho[$i];
if (($i+1) < sizeof($ho))
$s .= ",";
}
echo "your hobbies are : "$s;echo("</p>");


if(!isset($_POST['gender'])) 
 {
echo("<p>please select your gender</p>\n");
  } 
else 
 { 
$ho = $_POST['gender'];
for($i=0; $i<sizeof($ho); $i++)
{
$g .= $ho[$i];
}
         echo "You are ".$g;echo("</p>");



$con=mysqli_connect(@"localhost","root","","phpdemo") or die("Unable to connect to the database of Mysql name :  phpdemo");


if(mysqli_query($con,"create table tblreg(id int primary key auto_increment not null,username varchar(20),password varchar(20),hobbies varchar(40),gender varchar(6),emailid varchar(30),mobileno decimal(10,0))"))
{
echo "<br>Table created successfully.<br>";
}

$sql="insert into tblreg(`id`,`username`,`password`,`hobbies`,`gender`,`emailid`,`mobileno`) values(NULL,'$user','$pass','$s','$g','$email','$mobile');";
if(mysqli_query($con,$sql))
{
echo "successfully inserted into  the registration table ";
}
else
{
   echo "error".mysqli_error();
}


Fill country state city using php mysql

For selecting country in drop down list
The states are also filled auto matically from the database table as shown in the above figure.

<html>
<head>
<title>Fill Dropdown list</title>
<script language="javascript" type="text/javascript">
function showState(Country_Id)
{
 document.frm.submit();
}

</script>
</head>
<body>
<form name="frm" id="frm">

<?php
$con=mysqli_connect(@"localhost", "root", "","demo") or die("Connection Failed");
$query = "SELECT * FROM tbl_country";
$result = mysqli_query($con,$query);
?>
<select name="select1"  onChange="showState(this.value);">
<option value="">--- Select Country---</option>
<?php
while ($line = mysqli_fetch_array($result)) {
?>
<option value="<?php echo $line['id'];?>" <?php if($line['id']==$_REQUEST["select1"]) { echo

"Selected"; } ?> > <?php echo $line['countryname'];?> </option>
<?php
}
?>
<?php
$con=mysqli_connect(@"localhost", "root", "","demo") or die("Connection Failed");
$query = "SELECT * FROM tbl_state where cid='$_REQUEST[select1]'";
$result = mysqli_query($con,$query);
?>
</select>
<select name="select2"  >
<option value="">--- Select State---</option>
<?php
while ($line = mysqli_fetch_array($result)) {
?>
<option value="<?php echo $line['sid'];?>"> <?php echo $line['statename'];?> </option>
<?php
}
?>
</select>
</form>
</body>

</html>

For Learn Project Training with PHP Technologies
Visit Website : PHP Project Training Institute Vadodara, Gujarat, India.

Friday, 19 April 2013

Login form in PHP + MySQL

Create login.php and home.php

If valid username and password is entered by the user then he/she will access his/her HomePage.

login.php

where code and html document is there

<html>
<head>
<title>Login form</title>
<?php
if(isset($_POST['submit']))
{
$con=mysqli_connect(@"localhost","root","","demo");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$un=$_POST['username'];
$ps=$_POST['password'];

$result = mysqli_query($con,"SELECT * FROM tbladmin WHERE username='$un' and password='$ps'");
$row = mysqli_fetch_array($result);
$name = $row["username"];

$count=mysqli_num_rows($result);
  if($count==1)  {
 session_start();
 $_SESSION["user"]=$name;
 header("location:home.php");

  }
  else
  {
  echo "<div style=\"color:red\"><center>Invalid Username/Password</center></div>";
  }

mysqli_close($con);
}
?>
</head>

<body>
<form action="" method="post">
<center>
<h1>Admin LOGIN Form</h1>
<table >
<tr>
<td>
username:
</td>
<td>
 <input type="text" name="username">
</td>
</tr>
<tr>
<td>
password:
</td>
<td>
 <input type="password" name="password">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="submit" value="submit">
<input type="reset" name="reset" value="reset">
</td>
</tr>
</table>
</center>
</form>

</body>
</html>



home.php

Having the code to check session is started or Not.

<?php
session_start();
if(isset($_SESSION['user']))
{ $name=$_SESSION['user'];
 echo " welcome,$name";
}
else
{
 header("location:login.php");
}

?>

Thursday, 18 April 2013

Show Records using PHP + MySQL database connectivity in the website


PHPleqrn  Show Data of Database into the Tabular Format :

The Below Code will show the Columns
1.Username
2. Fullname 
3. Mobileno 
into the tabular format.


<?php
Echo "Show record of tbladmin";
$result = mysqli_query($con,"SELECT * FROM tbladmin");
echo "<table border=1>";
echo"<tr>
<th>Username</th>
<th>Fullname</th>
<th>Mobileno</th>
</tr>";
while($row = mysqli_fetch_array($result))
  {
  echo "<tr><td>".$row['username'] ."</td> <td> " . $row['fullname']." </td><td> ".$row['mobileno']."</td></tr>";

  }
 echo "</table>";
?>

For learning Project Training in Vadodara, Gujarat. Visit  website: www.vataliyatuitionclasses.com

Create New User Registration using PHP + MySQL Database connectivity


Write Insert Query to perform insert operation.

Direct Record fill by user itself <?php

// Create connection
$con=mysqli_connect(@"localhost","root","","Database1");


//Insert into table data
mysqli_query($con,"INSERT INTO tbladmin VALUES ('hitesh','hitesh','kumar','hiteshvataliya1@gmail.com','12391239123')");



?> 

By using Form user defined insert page


<html>
<head><title>Insert into Database</title>
<?php
if(isset($_POST['Submit'])){
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$name=trim($_POST['name']);
$number=trim($_POST['number']);
$email=trim($_POST['email']);

// Create connection
$con=mysqli_connect(@"localhost","root","","Database1");


//Insert into table data
$sql="INSERT INTO `database1`.`tbladmin` (`username`, `password`, `fullname`, `emailid`, `mobileno`) VALUES ('$username', '$password', '$name', '$email', '$number');";

if (mysqli_query($con,$sql))
{
echo "Success";
//final code will execute here.
}
}

?> 

</head>
<body>
<form name= "info" id= "info" method= "post" action= "" >
<table width= "327" border= "0" align="center" cellpadding= "5" cellspacing= "1">

<tr>
<td>Username: </td>
<td><input name= "username" type= "text" id= "username" value="" ></td>
</tr>
<tr>
<td>Password: </td>
<td><input name= "password" type= "text" id= "password" value=""  ></td>
</tr>
<tr>
<td width= "82" >FullName: </td>
<td width= "238" ><input name= "name" type= "text" id="name" value="" ></td>
</tr>
<tr>
<td> Email: </td>
<td><input name= "email" type= "text" id= "email" value="" ></td>
</tr>
<tr>
<td>Number: </td>
<td><input name= "number" type= "text" id= "number" value="" ></td>
</tr>
<tr>
<td></td>
<td><input type= "submit" name= "Submit" value= "Submit" /></td>
</tr>
</table>
</form>
</body>
</html>

For learning PHP project - visit website www.vataliyatuitionclasses.com


Create New Table using Mysql And PHP ???


Create table for admin registration having fields

id
username
password
fullname
emailid
mobileno

<?php

// Create connection
$con=mysqli_connect(@"localhost","root","","Database1") or die("Unable to connect to the database of Mysql name :  Database1");

//CREATE NEW TABLE
$sql="CREATE TABLE tbladmin(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
username VARCHAR(30),
password VARCHAR(30),
fullname VARCHAR(50),
emailid VARCHAR(50),
mobileno INT
)";

// Execute query
if (mysqli_query($con,$sql))
  {
  echo "Table tbladmin created successfully";
  }
else
  {
  echo "Error creating table: " . mysqli_error();
  }
?> 

How to connect PHP to MySQL ???


In web developement of php with mysql database it is must required to connect php form to the mysql database

$conn = mysqli_connect(“Server", “Username",“Password");



$conn is the varible in PHP.
mysqli_connect() :- is a method which is required to connect with the MySQL database
The attributes of the method are

Server – host name of server
Username - Username of Database
Password - Password of Database

Example :- 

if PC is works as a client and server then


$hostname='localhost';
$username='root';
$password='';
$conn = mysqli_connect($hostname,$username, $password) or die("Unable to connect to MySQL");
echo "<br>Now , Php for is connected to Mysql ";

              OR

$conn=mysqli_connect(@"localhost","root","“);


HTML and PHP code to Connect with MySQL using localhost and create new database using it.


<html>

<head>
<title>Demo</title>
</head>
<body>
Php form 
<?php
// Creating a connection to mysql

$hostname='localhost';
$username='root';
$password='';
$conn = mysqli_connect($hostname,$username, $password) 
  or die("Unable to connect to MySQL");
echo "<br>Now , Php for is connected to Mysql ";

$sql="CREATE DATABASE Database1";

if (mysqli_query($conn,$sql))
 {
 echo "<BR><BR>Database Database1 created successfully";
  }
else
  {
  echo "Error creating database: " . mysqli_error();
  }
?> 
</body>
</html>


What is PHP ???

PHP - Personnel Home Pages older name of php.

And Now it is Known as Hypertext PreProcessor.



PHP is the most widely used scripting language for web programming. 

PHP extends HTML pages by adding server-executed code segments to HTML pages.  

The output of the execution of the PHP code is merged into the HTML page.

PHP - Open Source Software. We don't have to pay any thing for using it. We can easily creates websites and web developement using PHP.

PHP - Which executes on the server.

The code is not shown in the view source of the page.

PHP is secure server side programming language.

PHP is easy to learn and use. we can easily embed it with HTML Page.

Example :-
<html>
<head><title>PHP with HTML</title>
</head>
<body>
<?php

//code of php


?>

</body>
</html>