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

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-06-2004, 02:39 PM
New kid on the block
 
Join Date: Jun 2004
Location: kl
Posts: 3
Rep Power: 0
adib is on a distinguished road
camne nak masuk DB??

mcm mane saya nak masuk kn data dlm DB kalo nak gune input type list/menu.
ni coding saya tp yang ni gune input type textfield...kalo input type list/menu camne ye??plizzzz tolong ajar saya..

<?php # Script 6.6 - register.php

//Set the page title and include the HTML header.
$page_title = 'Register';
include('templates/header.inc');

if(isset($_POST['submit'])) {//handle the form.

//Register the user in the DB.
require_once('mysql_connect.php'); //connect to DB.

//Create a function for escaping the data.
function escape_data($data) {
global $dbc; //Need the connection.
if(ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string ($data, $dbc);
} //end of function.

$massage = NULL; //Create an empty new variable.

// Check for a first name.
if (empty($_POST['first_name'])) {
$fn = FALSE;
$massage .= '<p>You forgot to enter your first name!</p>';
}else {
$fn= escape_data($_POST['first_name']);
}

//Check for a last name.
if(empty($_POST['last_name'])){
$ln = FALSE;
$massage .= '<p>You forgot to enter your last name!</p>';
} else {
$ln = escape_data($_POST['last_name']);
}

//Check for an email eddress.
if (empty($_POST['email'])) {
$e = FALSE;
$massage .= '<p>You forgot to enter your email address!</p>';
} else {
$e = escape_data($_POST['email']);
}

//Check for a username.
if(empty($_POST['username'])) {
$u = FALSE;
$massage .= '<p>You forgot to enter your username!</p>';
} else {
$u = escape_data($_POST['username']);
}

//Check for a password and match against the confirmed password.
if(empty($_POST['password1'])) {
$p = FALSE;
$massage .= '<p>You forgot to enter your password!</p>';
} else {
if($_POST['password1'] == $_POST['password2']) {
$p = escape_data($_POST['password1']);
} else {
$p = FALSE;
$massage .= '<p>Your password did not match the confirmed password!</p>';
}
}

if ($fn && $ln && $e && $u && $p) { //If everything's ok.

$query = "SELECT user_id FROM users WHERE username='$u'";
$result = @mysql_query ($query); //Run the query.
if(mysql_num_rows($result)==0){
//Make the query.
$query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";
$result = @mysql_query ($query); //Rub the query.
if( $result) { //If it ran OK.

//Send an email, if desired.
echo '<p><b>You have been registered!</b></p>';
include ('templates/footer.inc'); //include the html footer.
exit(); //quit the script.

} else { //If it did not run OK.
$massage = '<p>You could not registered due to a system erroe. We apologize for any inconvenience.</p><p>' .mysql_error().'</p>';
}
} else {
$massage = '<p>That username is already taken.</p>';
}
mysql_close(); //close the DB connection.

} else {
$massage .= '<p>Please try again.</p>';
}

} //End of the main Submit conditional.

//Print the massage if there is one.
if(isset($massage)) {
echo '<font color="red"', $massage, '</font>';
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend>

<p><b>First Name:</b> <input type="text" name="first_name" size="15" maxlength="15" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /> </p>

<p><b>Last Name:</b> <input type="text" name="last_name" size="15" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /> </p>

<p><b>Email Address:</b> <input type="text" name="email" size="15" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>

<p><b>User Name:</b> <input type="text" name="username" size="15" maxlength="10" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> </p>

<p><b>Password:</b> <input name="password1" type="password" id="password1" size="20" maxlength="20" /></p>

<p><b>Confirmed Password:</b><input type="password" name="password2" size="20" maxlength="20" /> </p>
</fieldset>

<div align = "center"><input type="submit"name="submit" value="Register" /></div>

</form><!--end of form-->

<?php
include('templates/footer.inc'); //Include the HTML footer.
?>

thanx!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-06-2004, 12:53 AM
lcf's Avatar
lcf lcf is offline
Pro-Blogger
 
Join Date: Feb 2003
Location: Kluang, Johor
Posts: 2,376
Rep Power: 118
lcf will become famous soon enough
Send a message via ICQ to lcf Send a message via MSN to lcf Send a message via Yahoo to lcf
don't quite understand what you want but maybe this will help you:

http://www.webxpertz.net/forums/showthread.php?t=28769
__________________
LiewCF | Malaysia Bloggers Forum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-06-2004, 06:55 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
check it out! or mr google will help u too
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
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
camne nak replace? heterozigot Website Programming 2 02-12-2004 10:07 AM
Jemputlah Masuk! Innovane Websites Review and Suggestion 14 12-04-2004 04:37 PM
camne nak limitkan db output?? sunshine Website Programming 1 02-09-2003 04:06 PM
Form field: Covert char ' dan " sebelum transfer masuk lam SQL server Tsar Website Programming 3 24-05-2002 06:42 PM
Form field: Covert char ' dan " sebelum transfer masuk lam SQL server Tsar Website Programming 2 20-05-2002 04:38 PM


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