Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-06-2007, 01:47 PM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Form Data

Bonjour (That's all the French I know!!!)

I'm currenlty using the following code, to add data from a form into a database called records. Does anybody know how I can stop dulicate records by checking to see if the name entered is already in the database?

Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("WB", $con);

$sql="INSERT INTO Records (Name, Age, Sex)
VALUES
('$_POST[Name]','$_POST[Age]','$_POST[Sex]')";

if (!mysql_query($sql,$con))
{
  die('Error: ' . mysql_error());
}
echo $_POST[Name] . "'s details were saved successfully!";

mysql_close($con)
?>
Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Table data from db as new form input tomycon PHP 2 03-03-2006 06:26 AM
How to insert HTML form data into mysql database ? plomon PHP 5 02-06-2005 09:23 AM
Passing form data to PHP with Javascript bdl PHP 5 07-03-2002 11:18 AM


All times are GMT -8. The time now is 08:47 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting