Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 26-05-2004, 05:46 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
Unhappy php coding...???

ello

mintak tulun sket sape terer php

nak wat form...

macam mane nak connet kan apa yg kita isi dekat form ke dalam database???
kantoi aa kat cording insert into ???

contoh la database = form
PHP Code:
data.php
<?php
$link 
mysql_connect("localhost""root""")
   or die(
"Takleh connet !!! error  : " mysql_error());
echo 
"Connected To Database...";
mysql_select_db("form") or die("Could not select database");

/* Performing SQL query */
$query "SELECT * FROM pelajar";
$result mysql_query($query) or die("Query failed : " mysql_error());
$sql_query mysql_query("INSERT INTO pelajar (nama, ic, alamat, email, tepon, komen) VALUES ('$nama', '$ic', '$alamat', '$email', '$tepon', '$komen')"); 
?>

<form METHOD=POST ACTION="data.php">
<table width="424" border="0" cellspacing="0" cellpadding="0" height="279"><tr>
<td width="131" height="23">Nama:</td><td width="293" height="23">&nbsp;<INPUT TYPE="text" NAME="nama" size="20"></td></tr><tr>
<td width="131" height="23">Alamat :</td><td width="293" height="23">&nbsp;<INPUT TYPE="text" NAME="alamat" size="20"></td></tr><tr>
<td width="131" height="23">i/c</td><td width="293" height="23">&nbsp;<INPUT TYPE="text" NAME="ic" size="20"></td></tr><tr>
<td width="131" height="23">No Tepon :</td><td width="293" height="23">&nbsp;<INPUT TYPE="text" NAME="tepon" size="20"></td></tr><tr>
<td width="131" height="23">E-mail :</td><td width="293" height="23">&nbsp;<INPUT TYPE="text" NAME="email" size="20"></td></tr><tr>
<td valign="top" width="131" height="181">komen:</td>
<td width="293" height="181"><TEXTAREA NAME="komen" ROWS="10" COLS="34"></TEXTAREA></td></tr>
<td width="131" height="1"><br>
<input type="submit" name="Hantar" value="Hantar"><input type="reset" name="Padam" value="Padam"></td>
<td width="293" height="1"><br>&nbsp;</td></tr></table></form>

Last edited by safprin; 26-05-2004 at 05:48 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 26-05-2004, 07:14 AM
hafizuddin's Avatar
Novice Webmaster
 
Join Date: May 2002
Location: Klate
Posts: 91
Rep Power: 82
hafizuddin is on a distinguished road
apa error yg kuar??
__________________
PHP Code:
<?php echo "PHP is a language?"?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 26-05-2004, 07:19 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
xde error yg kuar tp data yg kita masukkan kat form tu x pi ke database... dia create field kosong je...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 26-05-2004, 07:29 AM
hafizuddin's Avatar
Novice Webmaster
 
Join Date: May 2002
Location: Klate
Posts: 91
Rep Power: 82
hafizuddin is on a distinguished road
bukan kena assign value dari $_POST dulu ke?
macam $nama=$_POST['nama']
ke camne?
__________________
PHP Code:
<?php echo "PHP is a language?"?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 26-05-2004, 08:13 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
erm... ye kot... hehe try dulu...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 26-05-2004, 08:24 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
hehe... hafizuddin thanks aa bebanyak... mmg tul pun... ekeke nape la x terpk... puas cari tutorial... hampes je...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 26-05-2004, 09:58 AM
nurulmajdi's Avatar
Inspired Webmaster
 
Join Date: Feb 2004
Location: Klang Bandar Diraja
Posts: 160
Rep Power: 62
nurulmajdi is on a distinguished road
Send a message via Yahoo to nurulmajdi
www.phpfreaks.com.. antara yg best pernah aku jumpa laa.. good for beginner like u and me..
__________________
To follow the path:
Look to the master,
Follow the master,
Walk with the master,
See through the master,
Become the master.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 26-05-2004, 11:54 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
nurul majdi promote site tu ke... tempat lain pun ade gak awk letak... hehe... pape pun tangkiu bebanyak... besh gak tutorial tuh...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 26-05-2004, 11:59 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
camner lak kalau kita nak display semua data yg kita insert ??? ade sape˛ leh kasi tip?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 26-05-2004, 02:11 PM
paranoidz's Avatar
Novice Webmaster
 
Join Date: Jul 2002
Location: dalam perut bumi
Posts: 40
Rep Power: 0
paranoidz is on a distinguished road
wat lagi satu php file kat situ ko codekan tuk view data tu...

dalam forum nie ade...ko cube search...aku pun baru belajor gak...
__________________
<embed src="http://www.geocities.com/paranoidz02/new.swf" WIDTH=400 HEIGHT=55 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 26-05-2004, 02:43 PM
New kid on the block
 
Join Date: Dec 2003
Location: Kuala Lumpur, Malaysia
Posts: 6
Rep Power: 0
jianyuan is on a distinguished road
Send a message via ICQ to jianyuan Send a message via AIM to jianyuan Send a message via Yahoo to jianyuan
cuba:
PHP Code:
<?php
$link 
mysql_connect("localhost""root""");
   or die(
"Takleh connet !!! error  : " mysql_error());
echo 
"Connected To Database...";
mysql_select_db("form") or die("Could not select database");

/* Performing SQL query */
$query "SELECT * FROM pelajar";
$result mysql_query($query) or die("Query failed : " mysql_error());
$nama $_POST[nama];
$ic $_POST[ic];
$alamat $_POST[alamat];
$email $_POST[email];
$tepon $_POST[tepon];
$komen $_POST[komen];
$sql_query mysql_query("INSERT INTO pelajar (nama, ic, alamat, email, tepon, komen) VALUES '$nama', '$ic', '$alamat', '$email', '$tepon', '$komen')"); 
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 26-05-2004, 03:34 PM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
erm... macih...
tp coding nie leh sebarang ke?


PHP Code:
$nama=$_POST['nama'];      $nama $_POST[nama]; 
satu ade tanda 'nama' gik satu terus je... leh guna 2˛ ke?

Last edited by safprin; 26-05-2004 at 03:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 26-05-2004, 03:44 PM
nurulmajdi's Avatar
Inspired Webmaster
 
Join Date: Feb 2004
Location: Klang Bandar Diraja
Posts: 160
Rep Power: 62
nurulmajdi is on a distinguished road
Send a message via Yahoo to nurulmajdi
silap kot jianyuan, aku rs code ni utk mskkn data dlm db. utk fetch data dr db..

Quote:
cuba:
PHP Code:
<?php
$link 
mysql_connect("localhost""root""");
   or die(
"Takleh connet !!! error  : " mysql_error());
echo 
"Connected To Database...";
mysql_select_db("form") or die("Could not select database");

/* Performing SQL query */
$query "SELECT * FROM pelajar";
$result mysql_query($query) or die("Query failed : " mysql_error());
while(
$get_data=mysql_fetch_array($result))
{
    
$nama $get_data['nama'];
    
$alamat $get_data['alamat'];
}

echo 
"Nama pelajar : $nama <br>\n";
echo 
"Alamat pelajar : $alamat <br>\n";
?>
aku rasa cukupla ini yg perlu dijelaskn . yg lenlain tu aku rasa bleh dpt kat tutorial dlm internt ni.. seb baik aku yg jawab, kalau lcf.. mesti dia tanya ko balik "have u ask mr. google?"... hahahha...
__________________
To follow the path:
Look to the master,
Follow the master,
Walk with the master,
See through the master,
Become the master.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 26-05-2004, 03:47 PM
nurulmajdi's Avatar
Inspired Webmaster
 
Join Date: Feb 2004
Location: Klang Bandar Diraja
Posts: 160
Rep Power: 62
nurulmajdi is on a distinguished road
Send a message via Yahoo to nurulmajdi
Quote:
Originally posted by safprin
erm... macih...
tp coding nie leh sebarang ke?


PHP Code:
$nama=$_POST['nama'];      $nama $_POST[nama]; 
satu ade tanda 'nama' gik satu terus je... leh guna 2˛ ke?
takleh buat sebarang.. mmg kena letak single quote tu.. nnt ada error plak..
__________________
To follow the path:
Look to the master,
Follow the master,
Walk with the master,
See through the master,
Become the master.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 26-05-2004, 04:51 PM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
Wink

berjaya gak wat form yg nampak cam senang je tp susah gak... hampes tul...

sib baik jadi... macih pade yg membantu... hehe

PHP Code:
<?php
$link 
mysql_connect("localhost""root""")
   or die(
"Takleh connet !!! error  : " mysql_error());
echo 
"Connected To Database...";
mysql_select_db("form") or die("Could not select database");

$nama $_POST['nama'];
$ic $_POST['ic'];
$jantina $_POST['jantina'];
$keje $_POST['keje'];
$status $_POST['status'];
$alamat $_POST['alamat']; 
$poskod $_POST['poskod'];
$telefon $_POST['telefon'];
$henset $_POST['henset'];
$email$_POST['email'];

/* Performing SQL query */
$query "SELECT * FROM pelajar";
$result mysql_query($query) or die("Query gagal : " mysql_error());
$sql_query mysql_query("INSERT INTO `pelajar` (`nama`, `ic`, `jantina`, `keje `, `status`, `alamat`, `poskod`, `telefon`, `henset `, `email`) VALUES ('$nama', '$ic', '$jantina', '$keje', '$status', '$alamat', '$poskod', '$telefon', '$henset', '$email')"); 

/* Paparkan lam html HTML */
echo "<table border='1' cellpadding='0' cellspacing='1' bordercolor='#C4CBD1'>\n";
while (
$line mysql_fetch_array($resultMYSQL_ASSOC)) {
   echo 
"\t\t\t<tr>\n";
   foreach (
$line as $col_value) {
       echo 
"\t\t\t\t<td>$col_value</td>\n\n";
   }
   echo 
"\t\t\t</tr>\n";
}
echo 
"</table>\n";

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?>

Last edited by safprin; 26-05-2004 at 04:54 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote