|
|||
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!!! |
|
||||
don't quite understand what you want but maybe this will help you:
http://www.webxpertz.net/forums/showthread.php?t=28769 |
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
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.
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.













Linear Mode

