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

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2006, 03:00 PM
New kid on the block
 
Join Date: Jun 2006
Location: putrajaya
Posts: 5
Rep Power: 0
nanazack is on a distinguished road
Send a message via Yahoo to nanazack
kalo data xisi, xmasuk db

nak mintak tolong ckit, saya dah dapat insert data ke db...tp masalah skang, kalo data xisi pun, tetap masuk dalam database...ada sape2 lek adjustkn coding saya nie??? plz....................

<?php
$host="localhost";
$username="";
$password="";
$db_name="guestbook";
$tbl_name="guestbook";

mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");

$datetime=date("d-m-y h:i:s");
$name = $_POST['name'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$alamat = $_POST['alamat'];
$comment = $_POST['comment'];

$sql="INSERT INTO $tbl_name(name, tel, email, alamat, comment, datetime)VALUES('$name', '$tel', '$email', '$alamat', '$comment', '$datetime')";
$result=mysql_query($sql);

if($result){

echo "<BR>";
echo "Terima kasih di atas maklumbalas anda"; // link to view guestbook page
echo "<BR>";
echo "<BR>";
echo "<A href='javascript: self.close ()'>Tutup</A>";
}


mysql_close();
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-08-2006, 07:15 AM
robot's Avatar
Senior Webmaster
 
Join Date: Jul 2006
Location: My
Posts: 969
Rep Power: 48
robot will become famous soon enough
u kena filter supaya cuma bila ada element $_POST then INSERT baru boleh berlaku

PHP Code:
$name $_POST['name'];
$tel $_POST['tel'];
$email $_POST['email'];
$alamat $_POST['alamat'];
$comment $_POST['comment'];

$sql="INSERT INTO $tbl_name(name, tel, email, alamat, comment, datetime)VALUES('$name', '$tel', '$email', '$alamat', '$comment', '$datetime')";
if(
$tel && $email && $alamat && $comment)
{
$result=mysql_query($sql);

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-08-2006, 09:33 AM
New kid on the block
 
Join Date: Jun 2006
Location: putrajaya
Posts: 5
Rep Power: 0
nanazack is on a distinguished road
Send a message via Yahoo to nanazack
format insert emel lak...

yang tadi tu dah jd....thanks la pada robot ye...skang ni nak tanya lak, mcmne nak detect user tu xisi column salah satu yang di atas. cthnye mcm user xisi no tel, pastu bila user send, kuar alert suruh user isi no tel gak...

lagi 1, mcmne nak detect format emel yang betul? cth : user mesti masukkan emel yang betul macam "test@test.com". kalo user masukkan "test" je, kuar alert gak...

sape2 leh tolong tak??? plzz....

Last edited by nanazack; 02-08-2006 at 09:52 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-08-2006, 12:49 PM
robot's Avatar
Senior Webmaster
 
Join Date: Jul 2006
Location: My
Posts: 969
Rep Power: 48
robot will become famous soon enough
utk pastikan user masukkan semua data yg diperlukan
PHP Code:
if($tel && $email && $alamat && $comment)
{
$result=mysql_query($sql);
}
else
{
 if(!
$tel){print "tolong masukkan no tel";}
 if(!
$email){print "tolong masukkan email";}
 
// dan sebagainya

kita cuma boleh validate email format tetapi tidak boleh memastikan email tuh ori atau pun tidak
validate email input
PHP Code:
$email=$_POST["email"];
if(!
preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i',$email))
{
$msg="Email anda tidak betul. Anda tau tak aper tuh email?";
unset(
$email);

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
what different between bandwidth and data transfer? dongdong Paid Hosting Discussion Forum 10 30-03-2006 06:08 PM
sorting data gundam_seat Website Programming 2 06-08-2005 10:16 AM
Multiple data koisempoi Website Programming 5 06-12-2004 10:51 AM
av probs with dump sql data... Syazwan Website Programming 3 24-10-2004 10:11 PM
display data,camne??? adib Website Programming 14 21-08-2004 10:27 AM


All times are GMT +8. The time now is 02:01 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61