Hello everyones. I have a problem: I created the code to update a database. Everything work( no error message0 but when I go to see the table in the place where needed to be the updated information is nothing(""). Please help!

The file who update the information(ap1i_moc.php)
<?php
// Conectare la baza de date
require_once("database/connect.php");
// Transmitere informatii in variabile
$oferta=$_POST['CodOfertaVechi'];
echo $oferta;
$nume=$_POST['NumeProprietarNou'];
echo $nume;
$adresa=$_POST['AdresaNou'];
echo $adresa;
$telefon=$_POST['NumarTelefonNou'];
echo $telefon;
$email=$_POST['AdresaEmailNou'];
echo $email;
//Verificare informatii si actualizeazale
if(!$nume="") 
{
    $update1="UPDATE ap1i SET NumeProprietar='$nume' WHERE CodOferta='$oferta'";
    $ret1 = mysql_query($update1);
    if(!$ret1)
    {
        die('Could not update data: ' . mysql_error());
    } 
}
mysql_close($con);
?>


The HTML with the form code( another file):
<!---Versiunea 1.0--->
<!DOCTYPE>
<html>
<?php include("/home/a6704458/public_html/password_protect.php"); ?>
<head>
<link href="css/helper.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/button.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="ap1i_moc.php" method="post">
<h4>Introduce codul oferta pentru informatiile pe care le vrei sa le actualizezi.</h4></br>
Cod oferta: <input type="text" name="CodOfertaVechi" /></br></br>
<h4>Daca nu vrei ca o informatie sa nu fie actualizata lasa goala casuta.</h4></br>
Adresa: <input type="text" name="AdresaNou" /></br>
Nume proprietar: <input type="text" name="NumeProprietarNou"/></br>
Numar telefon: <input type="text" name="NumarTelefonNou"/></br>
Adresa email: <input type="text" name="AdresaEmailNou"/></br>
<input type="submit" class="abutton" /><a href="index.html" class="abutton">Home</a>
</form>
</body>
</html>

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

@prisacariualex

You need to add class="input" in the <input type>. I took out those <tags> so you can see how it looks like:

-

<form action="ap1i_moc.php" method="post">

Cod oferta: <input type="text" name="CodOfertaVechi" class="input" />

Adresa: <input type="text" name="AdresaNou" class="input" />

Nume proprietar: <input type="text" name="NumeProprietarNou" class="input" />

Numar telefon: <input type="text" name="NumarTelefonNou" class="input" />

Adresa email: <input type="text" name="AdresaEmailNou" class="input" />

<input type="submit" value="Submit" class="button" />

</form>

Didn't work.
Same resultat.
I introduced CodOfertaVechi and loaded it and I introduced only in NumeProprietarNou box the value '-tested-'. At final showed me value of CodOfertaVechi and the value of NumeProprietarNou, but when I verified the table I didn't founded at the NumeProprietar the value '-tested-', but I founded the value '', nothing. Please help. Or if can someone rewrite my code to work.
P.S.:What I maked with bold are values.

Member Avatar for LastMitch

@prisacariualex

I don't want to offended you but what language do you speak? I can't make out those words.

Please help. Or if can someone rewrite my code to work.

I'm just gonna modify the code not rewrite the code.

What is in this file: ap1i_moc.php?

So NumeProprietar box the value '-tested- not working? but the other does?

This is what I make out:

<?php

require_once("database/connect.php");

$oferta = " ";
$nume = " ";
$adresa = " ";
$telefon = " ";
$email = " ";

if ($_POST){
$oferta=$_POST['CodOfertaVechi'];
$nume=$_POST['NumeProprietarNou'];
$adresa=$_POST['AdresaNou'];
$telefon=$_POST['NumarTelefonNou'];
$email=$_POST['AdresaEmailNou'];

$update="UPDATE ap1i SET NumeProprietarNou='$nume' WHERE CodOfertaVechi='$oferta'";
$ret = mysql_query($update);
if(!$ret)
{
die('Could not update data: ' . mysql_error());
}
}
mysql_close($con);
?>

-

<form action="ap1i_moc.php" method="post">

Cod oferta: <input type="text" name="CodOfertaVechi" class="input" />

Adresa: <input type="text" name="AdresaNou" class="input" />

Nume proprietar: <input type="text" name="NumeProprietarNou" class="input" />

Numar telefon: <input type="text" name="NumarTelefonNou" class="input" />

Adresa email: <input type="text" name="AdresaEmailNou" class="input" />

<input type="submit" value="Submit" class="button" />

</form>

Thanks ofr helping, but I figured out: I deleted all and I restarted to make it :D .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.