Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 06-20-2007, 12:56 AM
Sergeant
 
Join Date: Jun 2007
Posts: 24
Default Inserting inputted data

I have this registration form im creating and was wondering how do i query so that what the user has inputted into the input box will be inserted to the table. I have this so far:



<?php
// Make a MySQL Connection
mysql_connect("localhost", "test", "test1") or die(mysql_error());
mysql_select_db("testdatabase") or die(mysql_error());

// Insert a row of information into the table "registrationdetails"
mysql_query("INSERT INTO registrationdetails
(Username) VALUES("What goes here") ?


**
I created the input box on a form in my html page. Now i wanted to know how do i know what to put after VALUES to make it insert the inputted data from the user to the row? is it sumin like "VALUES("editbox.name") ??

*Also how do i know which property it is in bluevoda to name the editbox to make it unique to all the other edit boxes on my registration page so i know which edit box i want to use to insert data to the table?

thanks to any help you can give
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 06-20-2007, 02:31 AM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,640
Default Re: Inserting inputted data

You will need to do something like...

$username = $_POST['username'];
$password = $_POST['password'];

$insert = mysql_query("INSERT INTO table (username, password) VALUES ('$username', '$password')");

Now you will also want check that the username doesn't contain characters like ' or ", which can be used with sql injection (hacks into your site).

You will also want to encrypt your password with either md5() or sha1(), you don't want plain text passwords stored anywhere on the internet (that includes files on the server, ie databases).

You want edit the "name" attribute of html form elements, that corresponds to the inside of $_POST[' '], (stuff in between ' ')
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


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

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


All times are GMT +1. The time now is 01:05 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

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