Jump to content
crv82

Sistem Check Keputusankemasukan....

Recommended Posts

:lol: saya nak wat system yg leh check keputusan kemasukan ke sekolah agama.

bile pemohon masukkan no ic...die kuar result samada berjaya atau tak...ala,mcm yg check kemasukan ke ipt tu...


<?
session_start();
// sambungan
$conn =mysql_connect('localhost','root','');

//pilih database
mysql_select_db("pemohon",$conn);

//arahan sql
$sql="select * from berjaya where no_ic= '$_GET[no_ic]'";
$rslt=mysql_query($sql);

if ($login =mysql_fetch_array($rslt))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " <br> ";
echo " $data["no_ic"] ";
echo " $data["nama"] ";
echo " $data["no_rujukan"] ";
echo " $data["sekolah_pilih"] ";
echo " $data["alamat"] ";
include ("berjaya.php");

}
else
{
include("gagal.php");
echo " <br> ";
}

?>[/codebox]

btul ker code kat atas tu..??itu sy try and error jerr...dan mmg error.. :lol: ..leh otai2 php tlg tak?

Share this post


Link to post
Share on other sites

:lol: saya nak wat system yg leh check keputusan kemasukan ke sekolah agama.

bile pemohon masukkan no ic...die kuar result samada berjaya atau tak...ala,mcm yg check kemasukan ke ipt tu...


<?
session_start();
// sambungan
$conn =mysql_connect('localhost','root','');

//pilih database
mysql_select_db("pemohon",$conn);

//arahan sql
$sql="select * from berjaya where no_ic= '$_GET[no_ic]'";
$rslt=mysql_query($sql);

if ($login =mysql_fetch_array($rslt))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " <br> ";
echo " $data["no_ic"] ";
echo " $data["nama"] ";
echo " $data["no_rujukan"] ";
echo " $data["sekolah_pilih"] ";
echo " $data["alamat"] ";
include ("berjaya.php");

}
else
{
include("gagal.php");
echo " <br> ";
}

?>[/codebox]

btul ker code kat atas tu..??itu sy try and error jerr...dan mmg error.. :lol: ..leh otai2 php tlg tak?

mcm silap aje hehehe

mana laa ko copy koding ni

mula2 ko buat $login

$login =mysql_fetch_array($rslt)

lepas tu papar $data[]

echo " $data["no_ic"] ";

nak tanya, mana datang $data[] tu kalau ko buat $login =mysql_fetch_array($rslt)

ni arahan yg biasa aku buat laa

[code]//arahan sql $sql="select * from berjaya where no_ic= '$_GET[no_ic]'"; $rslt=mysql_query($sql); $rows = mysql_num_rows($rslt); // cari bilangan baris // nak cari $rows if ($rows=='0'): include("gagal.php"); echo " <br> "; else: // mula kalau jumpa while($data = mysql_fetch_array($rslt))     {// mula papar $data[]     echo " Tahniah,Anda Berjaya";     echo " <br> ";     echo " <br> ";     echo " $data["no_ic"] ";     echo " $data["nama"] ";     echo " $data["no_rujukan"] ";     echo " $data["sekolah_pilih"] ";     echo " $data["alamat"] ";     include ("berjaya.php");     }// tutup papar $data[] endif; //tamat jika jumpa[/code]

Share this post


Link to post
Share on other sites
mcm silap aje hehehe
mana laa ko copy koding ni



:lol: wat sndiri....maklumle baru sbulan blajar...tu pun sndiri2..hehhehe,ntah pape jer koding sy tu..nway,tq..tq,nati sy cube ek...

Share this post


Link to post
Share on other sites

ni arahan yg biasa aku buat laa

//arahan sql
$sql="select * from berjaya where no_ic= '$_GET[no_ic]'";
$rslt=mysql_query($sql);
$rows = mysql_num_rows($rslt); // cari bilangan baris
// nak cari $rows
if ($rows=='0'): include("gagal.php"); echo " <br> ";
else: // mula kalau jumpa
while($data = mysql_fetch_array($rslt))
    {// mula papar $data[]
    echo " Tahniah,Anda Berjaya";
    echo " <br> ";
    echo " <br> ";
    echo " $data["no_ic"] ";
    echo " $data["nama"] ";
    echo " $data["no_rujukan"] ";
    echo " $data["sekolah_pilih"] ";
    echo " $data["alamat"] ";
    include ("berjaya.php");
    }// tutup papar $data[]

endif; //tamat jika jumpa
Aku tak faham kenapa nak guna while? Kan No IC ni unique. Mana boleh lebih daripada 1 :wacko: Kalau aku punya style pula:
<?
session_start();
// sambungan (ubah single quote kepada double quote)
mysql_connect("localhost","root",'') or die("Unable to connect");

//pilih database
mysql_select_db("pemohon") or die("Unable to select DB");

//arahan sql (pilih column mana nak guna)
$sql="select no_ic, nama, no_rujukan, sekolah_pilih, alamat from berjaya where no_ic= '$_GET[no_ic]'";
list($no_ic, $nama, $no_rujukan, $sekolah_pilihan, $alamat) = mysql_fetch_array($sql);

//No IC adalah unique so mesti ada la kan
if (!empty($no_ic))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " <br> ";
echo " $no_ic ";
echo " $nama ";
echo " $no_rujukan ";
echo " $sekolah_pilihan ";
echo " $alamat ";
include ("berjaya.php");
}

else
{
include("gagal.php");
echo " <br> ";
}
?>

Lagi elok kalau buat pemeriksaan sama ada no ic wujud ke tidak. Tapi memandangkan ni simple je, tak banyak proses rasa tak perlu la kot. B)

Edited by SHiDi

Share this post


Link to post
Share on other sites

ape fungsi session_start() kalau tak utiliaze bnda tu.

Betul gak soalan kau tu. Aku agak dalam file yang dia include tu dia gunakan session nieh

Share this post


Link to post
Share on other sites

include :

refer : http://au2.php.net/manual/en/function.include.php

salah satu function jgk dlm php untuk masukkan file cntoh include 'db.php';

cntoh dlm db.php :

<?php

$connect = mysql_connect($host,$user,$pass);

if(!$connect)
echo "can't connect to server";

?>[/code]

Contoh situasi :

page ko byk nk gna connection ke mysql cnth nak update,insert data searching and so on, so xkan ko nak taip coding db.php tu kat every page ko ye tak ?

so function include ni dpt memudahkn ko , panggil satu file je pastu dah bleh gna variable2 dlm page db.php tue :)

just my 0.5cents :P

Share this post


Link to post
Share on other sites

Aku tak faham kenapa nak guna while? Kan No IC ni unique. Mana boleh lebih daripada 1 :wacko:

Lagi elok kalau buat pemeriksaan sama ada no ic wujud ke tidak. Tapi memandangkan ni simple je, tak banyak proses rasa tak perlu la kot. B)

kenapa guna while??

ala, aku dah terbiasa guna while

lagi pun kalau guna while ($data = mysql_fetch_array($rslt))

$data[] tu dlm bentuk array

jadi aku boleh pakai nombor atau nama medan

biasanya dlm sistem nyg aku buat,

memang aku set standard mcm tu.

senang kalau nak ubah apa2

ada kalanya aku malas nak list medan satu2 jadi aku buat mcm ni aje

// dapatkan bilangan medan
$fields = mysql_num_fields($result) or die("Num Fields Failed/ Nama Medan Takde");

...
...
...

while($row = mysql_fetch_array($result))
{// mula papar $row
    echo ($bil++ % '2'=='0')? "<tr bgcolor='plum'>" : "<tr>";
    for ( $f = 0; $f < $fields; $f++ )
    {
    echo "<td>".$row[$f]."</td>\n";
    }
    echo "</tr>\n";
}// tutup papar $row

jika aku rasa nak papar medan tertentu aje

aku pakai nama medan

kalau medan tu banyak sangat,

aku pakai nombor yg berulang

pasal session_start() tu,

rasanya dia main letak aje.

takde pun tak apa.

pasal include pulak,

aku memang suka sangat guna.

lebih2 lagi kalau koding yg aku buat dah panjang berjela.

mcm buat karangan pulak :P

tapi biasanya orang guna include

untuk kod yg diulang beberapa kali

mcm

1) kod nak buka database

2) fungsi

3) class

4) kod yg .... :D

Share this post


Link to post
Share on other sites

include :

refer : http://au2.php.net/manual/en/function.include.php

salah satu function jgk dlm php untuk masukkan file cntoh include 'db.php';

cntoh dlm db.php :

<?php

$connect = mysql_connect($host,$user,$pass);

if(!$connect)
echo "can't connect to server";

?>

Contoh situasi :

page ko byk nk gna connection ke mysql cnth nak update,insert data searching and so on, so xkan ko nak taip coding db.php tu kat every page ko ye tak ?

so function include ni dpt memudahkn ko , panggil satu file je pastu dah bleh gna variable2 dlm page db.php tue :)

just my 0.5cents :P

ooo macam tuh kee...kk thak u my mentor :lol:

thank u to abg amin007 2 :lol:

Share this post


Link to post
Share on other sites

<?
// sambungan
$conn =mysql_connect('localhost','root','');

//pilih database
mysql_select_db("pemohon",$conn);
//arahan sql
$sql="select * from berjaya where no_ic= '$_GET[no_ic]'";
$rslt=mysql_query($sql);
$rows = mysql_num_rows($rslt); // cari bilangan baris

$nama=$_POST['nama'];
//$no_rujukan=$_POST['no_rujukan'];
$no_ic=$_POST['no_ic'];
$upsr=$_POST['upsr'];
$sekolah=$_POST['sekolah_pilih'];
$alamat=$_POST['alamat'];
$phone=$_POST['no_phone'];

// nak cari $rows
//No IC adalah unique so mesti ada la kan
if (!empty($no_ic))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " <br> ";
echo " $no_ic ";
echo " $nama ";
echo " $no_rujukan ";
echo " $sekolah";
echo " $alamat ";
include ("berjaya.php");
}
else
{
include("gagal.php");
echo " <br> ";
}
?>[/codebox]

error dapat:

[codebox]
Notice: Undefined index: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 17
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 21
Notice: Undefined index: upsr in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 25
Notice: Undefined index: alamat in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 26
Notice: Undefined index: no_phone in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 27

Tahniah,Anda Berjaya

830213035444

Notice: Undefined variable: no_rujukan in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 39

naper die papar no ic jer? yg lain tu xkuar...ape masalah ek?

Share this post


Link to post
Share on other sites

$sql="select * from berjaya where no_ic= '$_GET[no_ic]'";

$no_ic=$_POST['no_ic'];
Kenapa dekat SQL Query kau guna $_GET[] tapi masa initialised kau guna $_POST[]? Mana satu ni? EDIT: Dekat SQL query kau pun ada kesilapan. Patutnya $_GET['no_ic'] atau $_POST['no_ic'] (memandangkan tak tau kau guna mana satu)
"SELECT * FROM berjaya WHERE no_ic ='".$_POST['no_ic']."'";

Soalan lagi satu, kenapa kau retrieve value daripada DB tapi lepas tu bila assign values untuk variable kau guna $_POST[]? Confused ah.

Edited by SHiDi

Share this post


Link to post
Share on other sites

Kenapa dekat SQL Query kau guna $_GET[] tapi masa initialised kau guna $_POST[]? Mana satu ni?

EDIT: Dekat SQL query kau pun ada kesilapan. Patutnya $_GET['no_ic'] atau $_POST['no_ic'] (memandangkan tak tau kau guna mana satu)

"SELECT * FROM berjaya WHERE no_ic ='".$_POST['no_ic']."'";

Soalan lagi satu, kenapa kau retrieve value daripada DB tapi lepas tu bila assign values untuk variable kau guna $_POST[]? Confused ah.

betul kata shidi.

ko patut keluarkan data dari table

bukan dari $_POST[]

kan kita orang dah tunjuk cara2 nak masukkan variable dari table.

guna cara tu laa

Share this post


Link to post
Share on other sites

Ini aku buat lepas berbuka. Terasa nak tulis PHP lak. Lama tak tulis :lol:

Memula borang untuk user masukkan nombor IC:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Nombor IC: <input type="text" name="no_ic"/> <input type="submit" name="submit" value="Periksa" />
</form>
Lepas tu untuk buat pemprosesan:
<?php 
if (isset($_POST['submit']))
{
$no_ic = (int)$_POST['no_ic']; //pastikan hanya nombor yang dimasukkan sebagai no IC.

if (!empty($no_ic))
{
$sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
list($nama, $sekolah, $alamat) = mysql_fetch_array($sql);

if (!empty($nama))
{
echo "Rekod Ditemui:<br />No IC: ".$no_ic."<br />Nama: ".$nama."<br />Sekolah: ".$sekolah."<br />Alamat: ".$alamat;
}

else
{
echo "Tiada Rekod Ditemui";
}

}

else
{
echo "Nombor IC tidak sah";
}

}
?>

Ni kira paling sempoi la. Pepandai eh ubah ikut kesusaian B)

EDIT: contoh ni cuma menggunakan SATU file PHP

Edited by SHiDi

Share this post


Link to post
Share on other sites

$sql = "SELECT nama, sekolah FROM berjaya WHERE no_ic = '".$no_ic."'";
$rslt=mysql_query($sql);
$nama=$_POST['nama'];
[/codebox]

bile sy wat camni,kuar data tp xsume.dan still ader error

[codebox]
Notice: Undefined variable: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 18
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 28

Tahniah,Anda Berjaya

820710036010

tapi bile saya tukar _post tu kpd _get,kuar error.


Notice: Undefined variable: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 18
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 26
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 28

DUKACITANYA DIMAKLUMKAN ANDA GAGAL DALAM PERMOHONAN TERSEBUT.

UNTUK RAYUAN,SILA KLIK DI SINI
[/codebox]

bile sy check kat mysql,no_ic yg saya insert xsame dgn yg ader dlm database.pelik laa.utk no_ic tu saya wat sbg int .naper jadi camtu ye?

tlg...

Share this post


Link to post
Share on other sites

$sql = "SELECT nama, sekolah FROM berjaya WHERE no_ic = '".$no_ic." ' ";
$rslt=mysql_query($sql);
$nama=$_POST['nama'];
[/codebox]

bile sy wat camni,kuar data tp xsume.dan still ader error

[codebox]
Notice: Undefined variable: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 18
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 28

Tahniah,Anda Berjaya

820710036010

tapi bile saya tukar _post tu kpd _get,kuar error.


Notice: Undefined variable: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 18
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 26
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 28

DUKACITANYA DIMAKLUMKAN ANDA GAGAL DALAM PERMOHONAN TERSEBUT.

UNTUK RAYUAN,SILA KLIK DI SINI
[/codebox]

bile sy check kat mysql,no_ic yg saya insert xsame dgn yg ader dlm database.pelik laa.utk no_ic tu saya wat sbg int .naper jadi camtu ye?

tlg...

apasal aku terasa ni macam masalah dengan easyPHP bukan coding dia. amin? apa pendapat kau? Melainkan dia tak post code yang sepenuhnya :lol:

Share this post


Link to post
Share on other sites

apasal aku terasa ni macam masalah dengan easyPHP bukan coding dia. amin? apa pendapat kau? Melainkan dia tak post code yang sepenuhnya :lol:

aku pun rasa benda yg sama mcm ko rasa shidi

crv82 , apa kata ko copy contoh shidi buat ni

fail no_ic.php

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Nombor IC: <input type="text" name="no_ic"/> <input type="submit" name="submit" value="Periksa" />
</form>

<?php
if (isset($_POST['submit']))
{
$no_ic = (int)$_POST['no_ic']; //pastikan hanya nombor yang dimasukkan sebagai no IC.

if (!empty($no_ic))
{

 $conn =mysql_connect('localhost','root','');  // sambungan
 mysql_select_db("pemohon",$conn);//pilih database

 $sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
 list($nama, $sekolah, $alamat) = mysql_fetch_array($sql);

 if (!empty($nama))
 {echo "Rekod Ditemui:<br />No IC: ".$no_ic."<br />Nama: ".$nama."<br />Sekolah: ".$sekolah."<br />Alamat: ".$alamat;}

 else {echo "Tiada Rekod Ditemui";}

}

else{echo "Nombor IC tidak sah";}

}
?>
lepas tu cuba paste kat sini apa outputnya. kalau keluar juga mcm
Notice: Undefined variable: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 18
Notice: Undefined index: nama in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 24
Notice: Undefined index: no_ic in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 26
Notice: Undefined index: sekolah_pilih in c:\program files\easyphp1-8\www\yik\action_checkin.php on line 28

maknanya easyphp ko tu ada masalah.

kalau tak, maknanya koding ko buat tu tak betul laa.

nak selamat, koding ko jangan pakai langsung

pakai shidi punya.

tengok apa akan jadi

Edited by amin007

Share this post


Link to post
Share on other sites

ni error yg kuar bile sy copy koding shidi

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-8\www\yik\aminshidi.php on line 27
Tiada Rekod Ditemui [/codebox]

maksudnyer skarang ni koding sy masalah ek?ni keseluruhan koding sy

[codebox]<form id="form1" name="form1" method="post" action="try.php">
<div align="center">
<p align="center"><span class="style4">SILA MASUKKAN NOMBOR KAD PENGENALAN</span>
<span class="style11">
<input name="no_ic" type="text" id="no_ic" />
</span><span class="style8"> </span> <span class="style9"><br />
</span><br />
<input type="submit" name="Submit" value="HANTAR" />=;

try.php


<? // sambungan
$conn =mysql_connect('localhost','root','');

//pilih database
mysql_select_db("pemohon",$conn);

//arahan sql
$sql="select * from berjaya where no_ic= $_GET['no_ic']";
$rslt=mysql_query($sql);
$rows = mysql_num_rows($rslt);

// cari bilangan baris
$nama=$_GET['nama'];
$no_ic=$_GET['no_ic'];
$sekolah=$_GET['sekolah_pilih'];

// nak cari $rows//

if (!empty($no_ic))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " <br> ";
echo " $no_ic ";
echo " $nama ";
echo " $sekolah";
include ("berjaya.php");
}
else {
include("gagal.php");
echo " <br> ";
}
?>
[/codebox]

koding ni silap eh?? :huh:

Share this post


Link to post
Share on other sites

Erk... baru perasan coding aku ada silap. Ni la akibatnya coding tanpa testing :P

Silap kat line nieh:

$sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
list($nama, $sekolah, $alamat) = mysql_fetch_array($sql);
Ubah kepada:
$sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
$query = mysql_query($sql) or die("MySQL Error: ".mysql_error());
list($nama, $sekolah, $alamat) = mysql_fetch_array($query);
Tengok apa jadi lak. Btw aku tengok kau ada ubah gak coding aku nieh. Agak pelik gak ah :wacko:EDIT: Lagi sekali aku nak tanya, apa sebab kau retrieve data daripada Database tapi assign value berdasarkan $_GET[]?
// cari bilangan baris
$nama=$_GET['nama'];
$no_ic=$_GET['no_ic'];
$sekolah=$_GET['sekolah_pilih'];
Nilai daripada db langsung tak digunakan pun dalam coding kau. Dan ada kesilapan dalam SQL kau:
$sql="select * from berjaya where no_ic= $_GET['no_ic']";
Kan dalam form tu dah pilih method="post" kenapa guna $_GET[] pula?
$sql="SELECT * FROM berjaya WHERE no_ic = '".$_POST['no_ic']."'";
Aku tak faham logik dalam barisan ni:
$rows = mysql_num_rows($rslt);

Kenapa kau ada buat query nie? Untuk kira baris. Tapi tak nampak pun if statement atau apa pun yang gunakan $rows tu.

Edited by SHiDi

Share this post


Link to post
Share on other sites

crv82, koding ko memang silap

ko sepatutnya ambil data hasil dari sql.

data dlm bentuk $_POST[] atau $_GET[]

datang dari form/borang

bukan dari sql

kalau nak ambil data dari sql

buat mcm ni

$sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
$query = mysql_query($sql) or die("MySQL Error: ".mysql_error());
list($nama, $sekolah, $alamat) = mysql_fetch_array($query);

dengan lain perkataan data datang dari mysql_fetch_array($query)

bukan dari $_POST[] atau $_GET[]

silap konsep laa ko pakai

shidi, aku pun tak perasan ko punya koding silap hehehe :lol:

main copy ko punya, aku pun tak cek betul2

Share this post


Link to post
Share on other sites

data dlm bentuk $_POST[] atau $_GET[]

datang dari form/borang

bukan dari sql

Erk, kurang tepat tu. Untuk form kita gunakan $_POST[] dan $_REQUEST[]. $_GET[] pula digunakan untuk handle query. Contohnya: http://webaddress.com/index.php?query=test.

So bila nak check atau validation boleh gunakan:

$query = $_GET['query'];

Sekadar berkongsi pendapat :) Salah tolong betulkan ye B)

EDIT: @crv82 boleh tak gunakan tag code bukan codebox. Pasal tag codebox tu memang tak wujud.

Edited by SHiDi

Share this post


Link to post
Share on other sites

<form action="action_check33.php" method="post">
  <p>&nbsp;</p>
  <p align="center"><span class="style2">Masukkan Nombor IC Anda </span>: 
    <input type="text" name="no_ic"/>
    <br />
    <br />
    <input type="submit" name="submit" value="Hantar" />
  </p>
  <p>&nbsp;</p>
  <p>&nbsp; </p>
</form>
action_check33.php
 

<?php
if (isset($_POST['submit']))
{
$no_ic = (int)$_POST['no_ic']; //pastikan hanya nombor yang dimasukkan sebagai no IC.

if (!empty($no_ic))
{


$conn =mysql_connect('localhost','root','');  // sambungan
mysql_select_db("pemohon",$conn);//pilih database

$sql = "SELECT nama, sekolah_pilih, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
$query = mysql_query($sql) or die("MySQL Error: ".mysql_error());
list($nama, $sekolah_pilih, $alamat) = mysql_fetch_array($query);


if (!empty($nama))
{
echo " Tahniah,Anda Berjaya";
echo " <br> ";
echo " $no_ic ";
echo " $nama ";
echo " $sekolah";
echo " $alamat ";
include ("berjaya.php");


}

else
{
include("gagal.php");

}

}

else
{
echo "Nombor IC tidak sah";
}

}
?>

koding atas dah ok,xkuar error dah.tenkiu amin n shidi...

Share this post


Link to post
Share on other sites

CODE
$sql = "SELECT nama, sekolah, alamat FROM pelajar WHERE no_ic = '".$no_ic."'";
$query = mysql_query($sql) or die("MySQL Error: ".mysql_error());
list($nama, $sekolah, $alamat) = mysql_fetch_array($query);
ooo..rupanya cara2 nak amik data dr dbase guna koding atas ni ekk... sy masih konpius lagi ni...pasal assign value tu...nama2 mcm nama,sekolah,alamat tu kena sama ngan nama dlm field dlm mysql ek?
if (isset($_POST['submit']))

yg ni lak,aper maksud die?dah google tp kurang phm :lol:

Share this post


Link to post
Share on other sites

Erk, kurang tepat tu. Untuk form kita gunakan $_POST[] dan $_REQUEST[]. $_GET[] pula digunakan untuk handle query. Contohnya: http://webaddress.com/index.php?query=test.

So bila nak check atau validation boleh gunakan:

$query = $_GET['query'];

Sekadar berkongsi pendapat :) Salah tolong betulkan ye B)

EDIT: @crv82 boleh tak gunakan tag code bukan codebox. Pasal tag codebox tu memang tak wujud.

shidi, untuk form kita boleh set post atau get kat method

<form action="action_check33.php" method="post"> a

atau <form action="action_check33.php" method="get">

jadi nilai $_GET[] boleh dapat dari fom atau link.

hasilnya sama aje

ko baca topik ni - http://www.php.net.my/forum/thread.php/9/1105/

1) GET lazimnya untuk mendapatkan data, makala POST boleh digunakan untuk apa sahaja seperti mengemaskini data, memesan arangan atau menghantar email.

2) GET menghantar data melalui URL, maka keselamatanya diragui. URL ini akan tersimpan dalam browser's History dan sesiapa juga boleh membukanya semula. Sedangkan POST mencipta sambungan ke HTTP dan kemudian menghantar data ke server - tiada dalam History.

3) GET tak boleh hantar data yang besar kerana saiz URL cuma 256 character. POST boleh menghantar apa jua termasuk fail yang besar seperti binari dan zip.

satu lagi link pasal ni - http://www.cs.tut.fi/~jkorpela/forms/methods.html

crv82, pasal if (isset($_POST['submit]))

ni linknya - http://www.php.net/manual/en/function.isset.php

tu cuma nak cari nilai $_POST[submit] tu sama ada true atau false

pasal assign value tu...nama2 mcm nama,sekolah,alamat tu kena sama ngan nama dlm field dlm mysql ek?

tu kena tanya shidi sebab dia yg buat. :lol:

ada banyak cara nak assign value dari mysql.

yg dia buat tu salah satu cara.

pasal nama tu kena sama tu takde kaitan,

takut nanti ko pening pulak pakai value lain.

Share this post


Link to post
Share on other sites

saya ada satu lagi masalah....pasal mysql ni....

bile saye insert data dalam mysql...dlm kes sy ni sy nak insert no_ic.lepas insert,bile saya check dlm table,xsama ngan data yg saya masukkan.

naper jadi camtu ek?3 kali insert,nombor yg kuar lain tpi nilai sama.

cth sy masukkan no_ic 830810045676.bile check dlm table,kuar nombor ni 2147483647.bile saya insert no_ic yg lain,nombor ni jgk yg kuar.pelik laa.....

aper masalahnye ye?xpaham laa.tlg..

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...