PHP Classes

File: datamanage/customer-new.php

Recommend this page to a friend!
  Packages of Mathew   Data Manager   datamanage/customer-new.php   Download  
File: datamanage/customer-new.php
Role: Example script
Content type: text/plain
Description: customer-new
Class: Data Manager
Retrieve and store MySQL records using Web forms
Author: By
Last change:
Date: 13 years ago
Size: 4,093 bytes
 

Contents

Class file image Download
<?php
session_start();
include('config.php');
if(isset($_POST['Submit']))
{
    $postVal = $_POST;
    if($postVal['idVal'] == "")
    {
        $table = "customer";
        $postVal['ad_id'] = $_SESSION['uid'];
        $postVal['ad_dt'] = date('Y-m-d H:i:s');
        $postVal['is_cust'] = 1;
        $saveData = new saveForm($table,$postVal);
        if($saveData->addData())
        {
            echo "<script>alert('Data added successfully.')</script>";
            echo "<script>location.replace('customer-view.php')</script>";
            exit;
        }
        else
        {
            echo "<script>alert('Data was not added. Kindly try again later.')</script>";
        }
    }
    elseif($postVal['idVal'] != "")
    {
        $table = "customer";
        $postVal['ad_id'] = $_SESSION['uid'];
        $postVal['ad_dt'] = date('Y-m-d');    
        $postVal['is_cust'] = 1;
        $saveData = new saveForm($table,$postVal);
        if($saveData->updateData('id','idVal'))
        {
            echo "<script>alert('Data updated successfully.')</script>";
            echo "<script>location.replace('customer-view.php')</script>";
            exit;
        }
        else
        {
            echo "<script>alert('Data cannot be updated kindly try again later.')</script>";
        }
    }
}
$obj = "document.form2.cinfo";
if($_POST['idVal'] != "")
{
    $id = $_POST['idVal'];
    $sql = "select * from customer where id='$id' and is_cust=1";
    $row = $db -> select($sql);
    $data = $row[0];
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=$title?></title>

<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>

<body>


<form method="post" action="customer-new.php" name="form2" >
        <div class="leftColumn">        
            <input class="myinput"  type="hidden" name="idVal" value="<?=$id?>"/>
            <h2>Contact Information</h2>
            <label>Contact Person  :</label>
            <input class="myinput"  type="hidden" name="status" value="1" />
            <input class="myinput"  type="text" name="cname" value="<?=$data['cname']?>"  />
            <span class="red-text">*</span>
            <label>Department :</label>
            <input class="myinput"  type="text" name="dept" value="<?=$data['dept']?>"  />
            <label>Designation :</label>
            <input class="myinput"  type="text" name="desig" value="<?=$data['desig']?>"   />
            <label>Organization :</label>
            <input class="myinput"  type="text" name="org" value="<?=$data['org']?>"  />
            <label>Address :</label>
            <textarea  cols="" rows="" name="address"  ><?=$data['address']?></textarea>
            <label>City :</label>
            <input class="myinput"  type="text" name="city" value="<?=$data['city']?>"  />
            <label>State :</label>
            <input class="myinput"  type="text" name="state" value="<?=$data['state']?>"  />
            <label>Country :</label>
            <input class="myinput"  type="text" name="country" value="<?=$data['country']?>"  />
            <label>Pin :</label><input class="myinput"  type="text" name="pin" value="<?=$data['pin']?>"  />
            <label>Phone :</label><input class="myinput"  type="text" name="ph" value="<?=$data['ph']?>"  />
            <label>Fax :</label> <input class="myinput"  type="text" name="fax" value="<?=$data['fax']?>"  />
            <label>Mobile :</label> <input class="myinput"  type="text" name="mob" value="<?=$data['mob']?>"  />
            <label>Website :</label> <input class="myinput"  type="text" name="web" value="<?=$data['web']?>"  />
            <label>Email :</label> <input class="myinput"  type="text" name="email" value="<?=$data['email']?>"  />        
            <label>KST :</label> <input class="myinput"  type="text" name="kst" value="<?=$data['kst']?>"  />    
            <label>CST :</label> <input class="myinput"  type="text" name="cst" value="<?=$data['cst']?>"  />    
            <label>TIN :</label> <input class="myinput"  type="text" name="tin" value="<?=$data['tin']?>"  />
                        <p><label>&nbsp;</label>
                <input type="submit" class="button"  value="Save" name="Submit" />
                <input type="reset" class="button"  value="Reset" /></p>
            </p>
                
       </div>
                
    </div>
</form>    
</body>
</html>