|
alo kawan2...
ni nk tanya..kalau dalam databese tu kite set id sebagai primary key...
then dalam databese dah de contoh id=1234
then dalam form masukan id=1234
then kuar warning ckp dalam database dah de id tu...so nk wat cmne erk nk suh kuar warning ckp dlm data base xmsk n dah de id tu..?? |
|
|
|
|
|
|
|
xder dak open source ke sini... ermm.. tolong lah kami.. data reader dlm php cam nerr... pastuh assign dlm class .. ado.net dlm php cam nerkk.. xleh tolong... aku zero php... help kitorang.. kitorangg bdk baru ajarrr...... |
|
|
|
|
|
|
|
Reply #1 cloud_hardcore's post
konsepnya sama macam login...
kuar warning masa exception |
|
|
|
|
|
|
|
urmmm...
aku tye bdk2 ni sume ajar gne wizard dreamweaver...
so klu nk bace coding dreamweaver tu mmg xphm la..
cube ko paste coding proses login n form login...
nnt aku paham kan konsep tu.. |
|
|
|
|
|
|
|
2 cara..
1.
$sql = "INSER INTO table (id) VALUES (". $_POST['id'] .")";
if(!$query = mysql_query($sql))
{
echo mysql_error();
}
2. validate dulu id tu.......
$sql = "SELECT FROM table WHERE id = ". $_POST['id'];
$query = mysql_query($sql);
if($row = mysql_fetch_assoc($query)
{
echo "Error, duplicate ID";
}
else
{
"insert data";
} |
|
|
|
|
|
|
|
Reply #5 BorderManager's post
nape aku buat tak jadi erk ?? |
|
|
|
|
|
|
|
jgn la copy bulat2.... baca & faham la dulu. aku main taip je. aku pun tak test jln ke tak... |
|
|
|
|
|
|
|
mungkin xderr connectionn db, <br/>databasee x buat lagi.... <br/>mungkin member ko ajar x habisss.... php tuh aperr arr...... lupaaa arr...:@ |
|
|
|
|
|
|
|
cuber kau paste jer kat sini coding kau..
pastu bagitahu sekali..
pastu bagitahu aper yang xjadi..
kalau ader error paste error.. |
|
|
|
|
|
|
|
maybe ko bleh try cara nie
$sql = "SELECT * FROM table WHERE idMember=$_POST['id']";
$result = mysql_query($sql)or die('Connection failure');
if($row = mysql_fetch_assoc($result)){
if ($row['idMember'] == ' ') {
$sqlInsert = "INSERT INTO table VALUES($id_member)";
$rsInsert = mysql_query($sqlInsert) or die('Comment cannot be added');
}
}else{
**kat sini echo ape2 alert utk
e.g : echo "Duplicate ID cannot insert new record";
}
|
|
|
|
|
|
|
|
kalo pakai java script leh gak.. |
|
|
|
|
|
|
|
ni yg aku wat....
<?php
require 'files/header.inc.php';
if ( !isset($_POST['nokp']) || !isset($_POST['pass']) || !isset($_POST['repass']) || !isset($_POST['email']) || !isset($_POST['nama']) || !isset($_POST['alamat']) ||!isset($_POST['poskod']) || !isset($_POST['bandar']) || !isset($_POST['kerja']) || !isset($_POST['jantina']) || $_POST['nokp'] == '' || $_POST['pass'] == '' || $_POST['repass'] == '' || $_POST['email'] == '' || $_POST['nama'] == '' || $_POST['alamat'] == '' || $_POST['poskod'] == '' || $_POST['bandar'] == '' || $_POST['kerja'] == '' || $_POST['jantina'] == '' )
{
} else {
$nokp = $_POST['nokp'];
$pass = $_POST['pass'];
$repass = $_POST['repass'];
$email = $_POST['email'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$poskod = $_POST['poskod'];
$bandar = $_POST['bandar'];
$kerja = $_POST['kerja'];
$jantina = $_POST['jantina'];
$ret = mysql_query("SELECT * FROM $dbtable");
if (@mysql_num_rows($ret) != 0)
{
while ($row = mysql_fetch_array($ret))
{
if ($nokp == $row['nokp'])
{
?>
<script language=javascript>
window.alert (" No IC ini telah didaftar!! Sila pilih No IC yang lain");
</script>
<?
}
}
}
if ($error != '')
{
echo $error;
include 'files/footer.inc.php';
echo "<form method=\"post\" action=\"index.php\">\n";
exit;
}
$pass =($pass);
$pass2 =($pass2);
$keys = '`nokp`,`pass`,`repass`,`email`,`nama`,`alamat`,`poskod`,`bandar`,`pekerjaan`,`jantina`';
$values = "'$nokp','$pass','$repass','$email','$nama','$alamat','$poskod','$bandar','$kerja','$jantina'";
$ret = mysql_query("INSERT INTO $dbtable ($keys) VALUES ($values)");
if (!$ret)
{
//exit('<strong>Error: </strong>Couldn\'t insert into MySQL Database.<br />'.mysql_errno().': '.mysql_error());
echo "
<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
<font size=\"4\" >
<p align='center'>
<a href=\"daftarbaru.php\">Kembali Ke Bahagian Pendaftaran</a></font><p/>
</strong></font>";
} else { ?>
<script language=javascript>
window.alert ("Pendaftaran Anda telah berjaya. Sila Klik Kembali Ke Ruangan Login Untuk Memasuki Sistem!!");
</script>
<?
/*echo "
<p align='center'> <font size=\"4\" >
Pendaftaran Anda Telah Berjaya. Sila Klik kembali ke bahagian login untuk memasuki Sistem.<br />
";*/
}
}
include 'files/footer.inc.php';
?> |
|
|
|
|
|
|
| |
|