Wednesday, March 30, 2016

insert.php

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>Insert php</title>
    </head>
    <body>
        <a href="index.php">Home Page</a>
        <br/>
        <a href="update.html">Update customer</a>
        <br/>
        <a href="delete.html">Delete customer</a>
        
        
        <?php
        // step 1 = connect to the server 
        $con = mysql_connect("localhost:3306", "root", "");
        
        // step 2 = select the datedase
        mysql_select_db("dvdclub", $con);
        
        // step 4 = inser the new customer 
        $i = $_POST["1"];
        $f = $_POST["2"];
        $l = $_POST["3"];
        
        mysql_query("insert into customer values ('$i', '$f', '$l') ");
        
        if(mysql_affected_rows() > 0 )
        {
            echo "insert Succesfull<br/>";
            ?>
        
        <meta http-equiv="refresh" content="2;url=index.html"/>

        <?php
        }
        else
        {
            echo "insert Failed<br/>";
       
        ?>
        <meta http-equiv="refresh" content="2;url=insert.html"/>
        <?php
         }
        // step 4 = close the connection 
        mysql_close($con);
        
        ?>
    </body>
</html>

No comments

Post a Comment

follow me

All Rights Reserved by personal © 2015 - 2016
Powered By Blogger, Designed by Mohammed ARG