#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Php update.php problem


    please help me. I don't know why "tampil_brand.php" not show any update item from "form_update_brand.html" ? where's the false ?

    Form Input Data Brand.html
    PHP Code:
    <html>
        <
    head>
            <
    title>Form Input Data Brand</title>
        </
    head>
        <
    body>
            <
    form action"input_brand.php" method="post">
            <
    table algin "center">
                <
    tr>
                    <
    td colspan ="2"><div algin="center">
                    <
    h3>Form Input Brand</h3>
                    </
    div>
                    </
    td>
                </
    tr>
                
                <
    tr>
                    <
    td>ID Brand</td>
                    <
    td> : <input type="text" Name="id_brand" value=""></td>
                </
    tr>
                
                <
    tr>
                    <
    td>Brand</td>
                    <
    td> : <input name="brand" type="text" id="brand"></td>
                </
    tr>
                
                <
    tr>
                    <
    td colspan="2" algin="center"><p>
                    <
    p>
                        <
    input type="submit" name="submit" value="PROSES">
                        <
    input type="reset" name="reset" value="BATAL">
                    </
    td>
                </
    tr>
            </
    table>
            </
    form>
        </
    body>
    </
    html
    Form Rubah Data Brand.html (Form Brand Data Update)
    PHP Code:
    <html>
        <
    head>
            <
    title>From Rubah Data Brand </title>
        </
    head>
        <
    body>
            <
    form action "update_brand.php" metode "post">
            <
    table algin "center">
                <
    tr>
                    <
    td colspan "2"><div algin "center">
                    <
    h3>Form Rubah Data Brand</h3>
                    </
    div>
                    </
    td>
                </
    tr>
                
                <
    tr>
                    <
    td width ="105">ID Brand</td>
                    <
    td width ="224">:
                    <
    input type="text" Name="id_brand"></td>
                </
    tr>
                    
                <
    tr>
                    <
    td>New ID Brand</td>
                    <
    td>:
                    <
    Input name"new_id_brand" type"text"></td>
                </
    tr>
                
                <
    tr>
                    <
    td>Brand</td>
                    <
    td>:
                    <
    input type ="text" name"brand" ></td>
                </
    tr>
                
                <
    tr>
                    <
    td colspan"2" Algin ="center">
                    <
    input type ="submit" name="submit" value="rubah">
                    <
    input type ="reset" name"reset" value="batal"></td>
                </
    tr>
            </
    table>
            </
    form>
        </
    body>
    </
    html
    Data Brand Handphone.html (Handphone Data Brand)
    PHP Code:
    <html>
        <head>
            <title>Data brand Handphone</title>
        </head>
        <body>
            <h1>Daftar Brand Handphone</h1>
            <p>
            </p>
            <table border="1" algin="left" bordercolor="#666666" >
                <tr>
                    <th scope="col">ID brand</th>
                    <th scrope="col">Brand</th>
                </tr>
                <?php

                    $koneksi 
    mysql_connect("localhost","root","");

                    
    mysql_select_db("ponselkita");

                    
    $query "SELECT id_brand, brand FROM brand";

                    
    $hasil mysql_query($query);

                    while(
    $record mysql_fetch_row($hasil))
                    {
                        echo
                            
    "<tr><td>$record[0]</td><td>$record[1]</td></tr>";
                    }
                
    ?>
            </table>
        </body>

    </html>
    Input Brand.php
    PHP Code:
    <?php
    //login
    $koneksi mysql_connect("localhost" "root" "");
    //pilih data base
    mysql_select_db("ponselkita");
    //isi data
    $query "INSERT INTO brand (id_brand, brand) VALUES ($_POST[id_brand], '$_POST[brand]')";
    //eksekusi perintah insert
    $hasil mysql_query($query);
    ?>
    Update Brand.php
    PHP Code:
    <?php
    //login
    $koneksi mysql_connect("localhost" "root" "");
    //pilih data base
    mysql_select_db("ponselkita");
    //update data
    $query "Update brand SET id_brand=
    $_POST[new_id_brand] , brand = $_Post(brand)' ";
    $query "WHERE id_brand = $_Pos[id_brand]";

    //eksekusi perintah
    $hasil mysql_query($query);
    ?>
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Please read the new user guide to learn how to format a good question.

    Tampil_brand does not appear in any of the code snippets you've provided.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0
    Tampilan_brand.php (Brand View.php)
    PHP Code:
    <html>
        <head>
            <title>Data brand Handphone</title>
        </head>
        <body>
            <h1>Daftar Brand Handphone</h1>
            <p>
            </p>
            <table border="1" algin="left" bordercolor="#666666" >
                <tr>
                    <th scope="col">ID brand</th>
                    <th scrope="col">Brand</th>
                </tr>
                <?php

                    $koneksi 
    mysql_connect("localhost","root","");

                    
    mysql_select_db("ponselkita");

                    
    $query "SELECT id_brand, brand FROM brand";

                    
    $hasil mysql_query($query);

                    while(
    $record mysql_fetch_row($hasil))
                    {
                        echo
                            
    "<tr><td>$record[0]</td><td>$record[1]</td></tr>";
                    }
                
    ?>
            </table>
        </body>

    </html>
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Cross-posted at phpfreaks and chip.co.id.

    If you people spent more time asking good questions rather than trying to get some crap question into as many forums as possible, you might actually learn something and become better programmers.

    I mean, c'mon. You just dump a bunch of unformatted code into the forum, telling us that it "don't work". After ManiacDan asks you to improve your question and points you to the user guide, you dump the next bunch of unformatted, uncommented code into the forum. And then you repeat this for two other forums. Personally, I feel like you just farted into my face.

    Have you even looked at your own code? Have you considered maybe outputting the query to see what it says? Nah, I guess you were busy copypasting your question.

    Anyway, let's pretend you're only 11 and simply don't know any better. For your convenience, I've reduced the gigantic amount of 13 lines of code to 2 lines of code. Look really, really closely. Can you see it? I see two syntax errors, one typo, one logical error and two gaping security holes.

    PHP Code:
    $query "Update brand SET id_brand=$_POST[new_id_brand] , brand = $_Post(brand)' ";
    $query "WHERE id_brand = $_Pos[id_brand]"
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0
    sori i am just learning php. I just follow the php same like the book . Seriously i just don't know where the wrong.
    Here my new "update brand.php"

    Update Brand.php
    PHP Code:
    <?php
    //login
    $koneksi mysql_connect("localhost" "root" "");
    //pilih data base
    mysql_select_db("ponselkita");
    //update data
    $query "UPDATE brand SET id_brand= $_POST[new_id_brand], brand = '$_POST[brand]' ";
    $query "WHERE id_brand = $_POST[id_brand]";

    //eksekusi perintah
    $hasil mysql_query($query);
    header('location:form_update_brand.html');
    ?>
    Try to input in "form_update_brand.html" and the "tampil_brand.php" still not change (fail). thanks
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,016
    Rep Power
    376
    why dont you do as jacques said.. DEBUG your own code. output the query and run it in mysql.. he even told you there are mistakes..

    why are you not putting ' around your $_POST var in the query
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    I don't speak Indonesian, but it seems they already told him what he needs to know.

    Multilingual crossposting -- that's actually new.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0
    my friend fix it for me.
    I have false in here :

    Update brand.php---> make a new php code
    PHP Code:
    <?php
    //login
    $koneksi mysql_connect("localhost" "root" "");
    //pilih data base
    mysql_select_db("ponselkita");
    //isi data
    $idb=$_POST['id_brand'];
    $new=$_POST['new_id_brand'];
    $brand=$_POST['brand'];

    mysql_query("update brand set new_id_brand='$new', brand='$brand' where id_brand='$idb'");

    header('location:form_update_brand.html');
    ?>
    Form Update brand.html
    I just wrong type "method"
    PHP Code:
    <html>
        <
    head>
            <
    title>From Rubah Data Brand </title>
        </
    head>
        <
    body>
            <
    form action "update_brand.php" [B]method[/B] = "post"
    Mysql
    I make 3 tables
    id_brand (int) , brand (var), new_id_brand (int)

IMN logo majestic logo threadwatch logo seochat tools logo