Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index5.php
- <html>
- <head>
- </head>
- <body>
- <?php
- if(isset($_GET['success']))
- {
- echo "updated";
- }
- if(isset($_GET['delete']))
- {
- echo "deleted";
- }
- include('db.php');
- $query=$db->query("select * from form1");
- $result=$query->fetchAll();
- ?>
- <form method="POST" action="edit5.php" >
- <table border='1'>
- <tr>
- <td>name</td>
- <td>address</td>
- <td>phoneno</td>
- <td>gender</td>
- <td>state</td>
- <td>country</td>
- <td>action</td>
- </tr>
- <?php
- foreach($result as $row)
- {
- ?>
- <tr><td><?php echo $row['name'];?></td>
- <td><?php echo $row['address'];?></td>
- <td><?php echo $row['phone_no'];?></td>
- <td><?php echo $row['gender'];?></td>
- <td><?php echo $row['state'];?></td>
- <td><?php echo $row['country'];?></td>
- <td><a href="edit5.php?id=<?php echo $row['id'];?>">Edit</a> <a href="delete5.php?id=<?php echo $row['id'];?>">Delete</a> </td>
- </tr>
- <?php } ?>
- </table>
- </form>
- </body>
- </html>
- edit5,php
- <html>
- <head>
- </head>
- <body>
- <?php
- include('db.php');
- $id=$_GET['id'];
- $query=$db->query("select * from form1 where id=$id");
- $row=$query->fetch(PDO::FETCH_ASSOC);
- ?>
- <form method="POST">
- <table border='1'>
- <tr>
- <td>Name</td>
- <td><input type="text" name="name" value="<?php echo $row['name'];?>"></td>
- </tr>
- <tr>
- <td>Address</td>
- <td><textarea name="address" rows="10" cols="5" ><?php echo $row['address'];?></textarea></td>
- </tr>
- <tr>
- <td>Phone</td>
- <td><input type="text" name="phone" value="<?php echo $row['phone_no'];?>"></td>
- </tr>
- </tr>
- <tr>
- <td>Gender</td>
- <td>
- Male:<input type="radio" name="r1" value="male">
- Female:<input type="radio" name="r1" value="female">
- </td></tr>
- <tr>
- <td>State</td>
- <td><select name="state">;
- <option value="kerala">Kerala</option>
- <option value="Tamilnadu">Tamilnadu</option>
- </select>
- </td></tr>
- <tr>
- <td>Country</td>
- <td><select name="country">
- <option value="India">India</option>
- <option value="Pak">Pak</option>
- </select>
- </td></tr>
- <td><input type="submit" name="submit" value="update"></td>
- <td><input type="hidden" name="id" value="<?php echo $row['id'];?>">
- </tr>
- </form>
- </table>
- </body>
- </html>
- <?php
- include('db.php');
- if(isset($_POST['submit']))
- {
- $name=$_POST['name'];
- $phone=$_POST['phone'];
- $address=$_POST['address'];
- $gender=$_POST['r1'];
- $state=$_POST['state'];
- $country=$_POST['country'];
- $id=$_POST['id'];
- $query=$db->query("update form1 set name='$name',address='$address',phone_no='$phone',gender='$gender',state='$state',country='$country' where id='$id'");
- if($query==true)
- {
- header("location:index5.php?success=1");
- }
- else
- {
- echo "fail";
- }
- }
- ?>
- delete5.php
- <?php
- include('db.php');
- $id=$_GET['id'];
- $query=$db->query("delete from form1 where id=$id");
- if($query==true)
- {
- header("location:index5.php?delete");
- }
- else
- {
- echo "false";
- }
- ?>
- test1.php
- <html>
- <head></head>
- <body>
- <form method="POST" >
- <table border='1'>
- <tr>
- <td>Username<input type="text" name="username"</td>
- <td>Password<input type="text" name="password"</td>
- <td>Course</td>
- <td>Php<input type="checkbox" name="course" value="php"></td>
- <td>java<input type="checkbox" name="course" value="java"></td>
- <td><input type="submit" name="submit" value="submit"></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
- <?php
- include('db.php');
- if(isset($_POST['submit']))
- {
- $username=$_POST['username'];
- $password=$_POST['password'];
- $course=$_POST['course'];
- $query=$db->query("insert into form2(username,password,course)values('$username','$password','$course')");
- }
- ?>
- index2.php
- <html>
- <head>
- </head>
- <body>
- <form method="POST">
- Name: <input type="text" name="name">
- Address: <textarea name="address" cols="10" rows="5"></textarea>
- Phone no: <input type="text" name="phoneno">
- Male<input type="radio" name="r1" value="male">
- Female<input type="radio" name="r1" value="female">
- Country: <select name="country">
- <option value="India">India</option>
- <option value="pak">Pak</option>
- </select>
- State: <select name="state">
- <option value="Kerala">Kerala</option>
- <option value="Tamilnadu">Tamilnadu</option>
- </select>
- <input type="submit" name="submit" value="submit">
- </form>
- </body>
- </html>
- <?php
- include('db2.php');
- if(isset($_POST['submit']))
- {
- echo $name=$_POST['name'];
- echo $address=$_POST['address'];
- echo $phoneno=$_POST['phoneno'];
- echo $gender=$_POST['r1'];
- echo $state=$_POST['state'];
- echo $country=$_POST['country'];
- $query=$db->query("Insert into form1(name,address,phone_no,gender,state,country) values('$name','$address','$phoneno','$gender','$state','$country')");
- if($query==true)
- {
- echo "success";
- }
- else
- {
- echo "fail";
- }
- }
- ?>
- db.php
- <?php
- $dsn="mysql:host=localhost;dbname=register";
- $username="root";
- $password="";
- $db=new PDO($dsn,$username,$password);
- ?>
- editable.php
- <html>
- <head>
- </head>
- <body>
- <?php
- include('db.php');
- $query=$db->query("select * from form where id=1");
- $result=$query->fetchAll();
- ?>
- <form action="edit.php" method="POST">
- <table border='1'>
- <tr><td>name</td>
- <td>address</td>
- <td>phoneno</td>
- <td>action</td>
- </tr>
- <?php
- foreach($result as $row)
- {
- ?>
- <tr><td><?php echo $row['name'];?></td>
- <td><?php echo $row['address'];?></td>
- <td><?php echo $row['phone_no'];?></td>
- <td><input type="submit" name ="edit" value="edit"></td>
- </tr>
- <?php } ?>
- </table>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment