July 15th, 2013, 10:28 PM
-
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);
?>
July 16th, 2013, 09:42 AM
-
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.
July 16th, 2013, 10:36 PM
-
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>
July 17th, 2013, 02:21 AM
-
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]";
July 18th, 2013, 02:43 AM
-
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
July 18th, 2013, 04:49 AM
-
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
July 18th, 2013, 06:01 AM
-
July 19th, 2013, 11:52 PM
-
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)