Posts

Php Short Course Crud

Login Page with Session  <?php include '../dbconn.php'; session_start(); if(isset($_POST['submit'])) {  $name =$_POST['uname']; $pass =$_POST['pass']; $query = mysqli_query($conn,"select * from user where name='$name' And password='$pass' "); $row =mysqli_fetch_array($query); if(mysqli_num_rows($query)>0) { $_SESSION['user'] = $row['id']; echo $_SESSION['user']; header("location:input.php"); } } ?> <html> <head> <title></title></head> <body> <form method="post" action=""> Username<input type="text" name="uname"><br> Password<input type="password" name="pass"><br> <input type="submit" name="submit" value="submit"><br> </form> ...

Complete Php

Db.php  <?php $host = "localhost"; $user = "root"; $pass = ""; $db   = "practice"; $link =mysqli_connect($host,$user,$pass,$db) or die(mysqli_error()); if($link) { echo "Database Connected Successfully"; } else { echo "Not Connected with a database"; } ?> insert.php <?php include 'db.php'; $phone = $_POST['phone']; $sql =mysqli_query($link,"insert into user (phone) values ('$phone')  "); ?> <hr> Welcome to insert page <br> <a href="logout.php">Logout</a><a href="show.php">show php</a> <form method="post" action=""> Phone<input type="text" name="phone" > <input type="submit"> </form> Show.php with Edit starts here <?php include 'db.php'; $sql = ("select * from user "); $re...

Crud

Db.php <?php mysql_connect("localhost","root",""); mysql_select_db('crud'); echo "crud Database" ?>              ====================================================== <?php // Steps Edit ////////////////////Show data in the edit field // 1 connection // $id = $_GET['edit']; variable to get data from the last page from <a href="edit.php?edit=' $row['id']">edit</a> //$query = mysql_query("select * from table where id='$id' "); //catch data in $row = mysql_fetch_array($query); //Show data in input field in value="<?php echo $row['id']; > " /////////////// // Update data // if(isset($_POST['update'])){ // set variable names $name=$_POST['name']; and phone etc //$update = "update table set name ='$name' , phone='$phone' where id='$id' "; // $result =mysql_query($update); //} in...

apple4

7:page edit.php <?php include 'db.php'; $id = $_GET['edit']; echo $id; $query=mysql_query("select * from apple where id='$id' "); $row =mysql_fetch_array($query);  if(isset($_POST['save']))  { $name = $_POST['name']; $up = "update apple set name = '$name' where id = '$id' "; $results =mysql_query($up); echo "successfully updated"; } ?> <h1><a href="index.php">Back</a></h1> <form action="" method="post"> Name: <input type="text" name="name" value="<?php echo $row['name']; ?> "> <input type="submit" value="update" name="save"> </form> ////////////////////////////End//////////////////////////// 8: page delete.php <?php include 'db.php'; $id = $_GET['delete']; $del = "DELETE FROM appl...

apple3

5:page login2.php <!-- Text input--> <div class="form-group">   <label class="col-md-4 control-label" for="user">User Name</label>    <div class="col-md-4">   <input id="user" name="user" type="text" placeholder="user name" class="form-control input-md">   <span class="help-block">Please enter user name</span>    </div> </div> <?php include 'db.php'; $name = $_POST['user']; $pass = $_POST['pass']; $check =mysql_query("select * from user where username='$name' and password='$pass' "); $row = mysql_fetch_array($check); if($row['username']== $name & $row['password']== $pass) {   echo "login successful" .$row['username']; }else{   echo "login failed"; } ?> /////////////////////////////////////////End//////...

apple2

3 Page:insert.php <h1><a href="index.php">Back </a></h1> <?php include 'db.php'; $name = $_POST['name']; $insert = mysql_query("insert into apple(name) values ('$name') "); echo $name; echo "Data inserted successfully"; ?> <form action="" method="post"> Name: <input type="text" name="name"><br /> <input type="submit" value="Enter" name="enter"> </form> <h1> List of Companies <a href="Logout.php"> click here to log out</a></h1> //////////////////////////////////////////////////End////////////////////////// 4:Page login.php <?php  session_start("name"); include 'db.php'; $user = $_POST['user']; $pass = $_POST['pass']; //echo $user; //echo $pass; //var_dump($_POST); $user =stripcslashe...

apple

1: Page: db.php  // to make connection  <?php mysql_connect("localhost","root","");  mysql_select_db('login'); echo "Login database"; ?> //////////End/////////// 2: Page index.php <?php include "db.php";      if(isset($_POST['enter'])) { $name =$_POST['name']; echo $name; $in = "insert into apple (name) values('$name')"; $re = mysql_query($in); } $show = "select * from apple "; $results =mysql_query($show); echo "<table class=\"table table-striped\">       <tr>             <th>ID</th>             <th>Name</th>             <th>Edit</th>             <th>Delete</th>             <th>insert</th>       </tr>"; while ($row = mysql_fetch_array($results)) {...