PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nukleus011
Forum Newbie
Posts: 2 Joined: Mon Mar 24, 2014 6:54 pm
Post
by nukleus011 » Mon Mar 24, 2014 7:22 pm
I'm trying to make a code to verify that the entry exists for the user name (kl_korisnicko_ime), but somewhere wrong. Help me!
Code: Select all
<?php
if(isset($_POST['submit']))
{
$kl_korisnicko_ime= $_POST['kl_korisnicko_ime'];
$dbc=mysqli_connect("localhost","root","123","stamparija");
$check=mysqli_query($dbc,"select * from clients where kl_korisnicko_ime='$kl_korisnicko_ime'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0){echo "Klijent postoji.";}
else{
//insert results from the form input
$query = "INSERT IGNORE INTO klijenti(kl_korisnicko_ime) VALUES('$kl_korisnicko_ime')";
$result = mysqli_query($dbc, $query) or die('Error querying database.');
mysqli_close($dbc);
}
echo "Klijent dodan u bazu.";};
$query="INSERT INTO klijenti (kl_korisnicko_ime, kl_sifra, kl_naziv_firme, kl_adresa_firme, kl_br_telefona_firme, kl_fax_firme, kl_mail_adresa_firme, kl_kontakt_osoba, kl_pozicija_u_firmi, kl_broj_telefona_kontakt_osoba, kl_mail_adresa_kontakt_osoba)
VALUES
('$_POST[kl_korisnicko_ime]','$_POST[kl_sifra]','$_POST[kl_naziv_firme]','$_POST[kl_adresa_firme]','$_POST[kl_br_telefona_firme]','$_POST[kl_fax_firme]','$_POST[kl_mail_adresa_firme]','$_POST[kl_kontakt_osoba]','$_POST[kl_pozicija_u_firmi]','$_POST[kl_broj_telefona_kontakt_osoba]','$_POST[kl_mail_adresa_kontakt_osoba]')";
?>
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Mon Mar 24, 2014 8:54 pm
Could you elaborate on what's going wrong? What errors are you encountering?
nukleus011
Forum Newbie
Posts: 2 Joined: Mon Mar 24, 2014 6:54 pm
Post
by nukleus011 » Tue Mar 25, 2014 6:29 am
There is no message after entering into a labels.
<html>
<body>
<form action="insert_kl.php" method="post" action='#' >
Korisničko ime:<label> <input type="text" name="kl_korisnicko_ime" required/></label>
Šifra: <label><input type="text" name="kl_sifra" required/></label>
Naziv firme: <label><input type="text" name="kl_naziv_firme" required/></label>
Adresa firme: <label><input type="text" name="kl_adresa_firme" required/></label>
Broj telefona firme:<label> <input type="text" name="kl_br_telefona_firme" required/></label>
Faks firme: <label><input type="text" name="kl_fax_firme" ></label>
E-mail firme:<label> <input type="text" name="kl_mail_adresa_firme" required/>></label>
Ime i prezime kontakt osobe:<label> <input type="text" name="kl_kontakt_osoba" required/>></label>
Pozicija u firmi: <label><input type="text" name="kl_pozicija_u_firmi" required/></label>
Broj telefona kontakt osobe:<label> <input type="text" name="kl_broj_telefona_kontakt_osoba" required/></label>
E-mail kontakt osobe:<label> <input type="text" name="kl_mail_adresa_kontakt_osoba" required/></label>
<input type="submit" value="pošalji">
</form>
</body>
</html>
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 25, 2014 7:09 am
Do you have error reporting enabled? Have you checked your PHP logs? Have you checked mysqli_error()? "It doesn't work" really doesn't give us anything to work with.