Jump to content

nivekz

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Posts posted by nivekz

  1. Creating a ecommerce website for my college project.And I have to Create a admin panel where i am able to modify my customer details so this idea struck me but ecexuting this has become a problem.Any other ways to edit my customer details with respect to the primary key which is the customer's id

  2. Hi guys need some help.I created a simple Update Customer Details page Where you Enter the Customer ID ,The Customer Details Get Displayed inside a Form and you make changes within the Form.But the update query I wrote is not working as it should be.It Executes the Query ,when I hardcode the Customer ID inside the Update query but fails when I need to Enter the Customer ID directly from the form using post.In This Code I tried to Update only the Customer's Firstname.Thanks

    Here Is The Code

    <?php
    $db=mysql_connect("localhost","root","") or die('Unable to Connect To Database.Please check the Database Parameters');
    mysql_select_db('ecommerce') or die(mysql_error());
    
    if(isset($_POST['enterid']))
    {
    $_POST['inputid'];
    }
    
    $query="SELECT * FROM customer WHERE Cid='$_POST[inputid]'";
    $result=mysql_query($query) or die(mysql_error());
    $row=mysql_fetch_array($result);
    $new_cid=$row['Cid'];
    $new_firstname=$row['Cfname'];
    $new_lastname=$row['Clname'];
    $new_email=$row['Email_id'];
    $new_address=$row['Address'];
    $new_pincode=$row['Pincode'];
    $new_payment=$row['Mode_of_payment'];
    $new_city=$row['City'];
    $new_state=$row['State'];
    $new_phone=$row['Phone'];
    
    $html1=<<<HTML1
    <form action="updatecustomer.php" method="post">
    <p class="inputidentifier">Please Enter The Customer's ID</p><input type="text" style="width:375px;height:40px;font-size:30px;" name="inputid" size="20"><br><br>
    <input type="submit" name="enterid" style="height:40px">
    HTML1;
    
    print($new_cid);
    
    if(isset($_POST['update']))
    {
      $query1="UPDATE customer SET Cfname='$_POST[firstname]' WHERE Cid='$_POST[inputid]'";
      mysql_query($query1) or die(mysql_error());
      if(mysql_affected_rows()==1)
      print("Query sucessful");
      else
      print("Something went wrong");
    }  
    ?>
    <html>
    <head>
    <style type="text/css">
    .inputtext {width:300px; height:40px;font-size:30px;}
    .inputidentifier{font-size:25px;font-family:"Arial"}
    .h1type{font-family:"Arial"}
    </style>
    <title>Test</title>
    </head>
    <body>
    <?php print($html1); ?>
    <h1 align="center" class="h1type">Update Customer Details</h1>
    <form action="updatecustomer.php" method="POST">
    <table align="center" cellspacing="10" cellpadding="10" border="0" width="60%">
    <tr>
    <td align="right" class="inputidentifier">First Name</td>
    <td align="left"><input type="text" class="inputtext" name="firstname" placeholder="eg:Kevin" value="<?php print($new_firstname) ?>"></td>
    </tr>
    <tr>
    <td align="right" class="inputidentifier">Last Name</td>
    <td><input type="text" class="inputtext" name="lastname" placeholder="eg:Aloysius" value="<?php print($new_lastname) ?>"></td>
    </tr>
    <tr>
    <td align="right" class="inputidentifier">E-mail</td>
    <td align="left"><input type="email" style="width:500" class="inputtext" name="email" placeholder="yourname@email.com" value="<?php print($new_email) ?>">
    </tr>
    <tr>
    <td align="right" class="inputidentifier">Phone Number</td>
    <td align="left"><input type="text" class="inputtext" name="phone" placeholder="How Do We Call You?" value="<?php print($new_phone) ?>"></td>
    </tr>
    <tr>
    <td align="right" class="inputidentifier">Address</td>
    <td><textarea style="width:500;height:150" wrap="virtual" class="inputtext" name="address" placeholder="Where is your Crib?"><?php print($new_address) ?></textarea></td>
    </tr>
    <tr>
    <td align="right" class="inputidentifier">State</td>
    <td align="left"><input type="text" style="width:500" class="inputtext" name="state" placeholder="State" value="<?php print($new_state) ?>">
    </tr>
    <tr>
    <td align="right" class="inputidentifier">City</td>
    <td align="left"><input type="text" class="inputtext" name="city" placeholder="City" value="<?php print($new_city) ?>">
    </tr>
    <tr>
    <td align="right" class="inputidentifier">Pin Code</td>
    <td><input type="text" class="inputtext" name="pincode" placeholder="Mulund 400080" maxlength="6" value="<?php print($new_pincode) ?>"></td>
    </tr>
    <tr>
    <td align="right" class="inputidentifier">How do Pay for your Bling?</td>
    <td align="left">
    <input type="text" class="inputtext" name="payment" value="<?php print($new_payment)?>">
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="update" value="Update!" style="width:100px;height:60px;"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    

  3. guys this thing called isset() is bugging me.What is the difference in when you say

    if(isset($_POST['name']))
    

    and

    if($_POST['name'])
    

    and

    if(!$_POST['name'])
    

     

    and why would someone require a code such as

    if($_POST['submit']=='Submit')

     

    And what is that code which tells you the user has entered something into the form

    Thanks People

  4. Hey guys my code is like this

    <?php
      if( $_POST["name"] || $_POST["age"] )
      {
         echo "Welcome ". $_POST['name']. "<br />";
         echo "You are ". $_POST['age']. " years old.";
         exit();
      }
    ?>
    <html>
    <body>
      <form action="<?php $_PHP_SELF ?>" method="POST">
    
      Name: <input type="text" name="name" />
      Age: <input type="text" name="age" />
    
      <input type="submit" />
      </form>
    </body>
    </html>
    

    The Inputs are taken from form.How do I make it display somewhere at the bottom of the form in the same page.The Output of this code comes up in a new page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.