473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

INSERT New Member in to DATABASE

Hi

I am trying to create a form for new member to create an account. There are 2 php files. File 1 [nuform.php] is a form where user can enter their data for registration purpose. File 2 [nm.php] sends typed data to database. My problem is I cann't send MySQL query to database to add a new account. Can any one help me.

file 1 'nuform.php'
Expand|Select|Wrap|Line Numbers
  1.  <html>
  2.  
  3. <title> Member Information</title>
  4. <?php
  5. echo
  6.      "<form action='nm.php' method='post'>
  7.     <p>Login Name  <input type='text' name='loginName'></p>
  8.      <p>Surname     <input type='text' name=Surname'></p>
  9.     <p>First Name  <input type='text' name='Firstname'></p>
  10.      <p>Select your Country</p>
  11.      <p><SELECT name="live"></p>
  12.      <p><option value="France">France</p>
  13.      <p><option value="Spain">Spain</p>
  14.      <p><option value="Australia">Australia</p>
  15.      <p><option value="United Kingdom">United Kingdom</p>
  16.      </SELECT>
  17.      <p><input type='Submit'></p>
  18.      </form>"
  19.  
  20. </html>
  21. ?>
  22.  
  23. file 2 'nm.php'
  24.  
  25. <?php
  26.  
  27.  
  28. $user="username";
  29. $host="localhost";
  30. $password="password";
  31. $database = "test";
  32.  
  33.  
  34. $connection = mysql_connect($host,$user,$password) //open connection to MySQL
  35.         or die ("couldn't connect to server");
  36.  
  37.  
  38. $db = mysql_select_db($database,$connection) // open session to Database
  39.         or die ("Couldn't select database");
  40.  
  41. $sql= "INSER INTO member (loginName, Surname, Firstname, live)values '".$_POST['loginName']." ".$_POST['Surname']." ".$_POST          ['Firstname']." ".$_POST['live']."'"
  42.  
  43. ?>
Mar 25 '08 #1
11 1499
Markus
6,050 Expert 4TB
USe code tags to display code on this forum.

You don't need to insert your own numbers if you do this.

Thanks.
Mar 25 '08 #2
USe code tags to display code on this forum.

You don't need to insert your own numbers if you do this.

Thanks.
thanks for telling me
Mar 25 '08 #3
ronverdonk
4,258 Expert 4TB
To debug this, echo the $sql statement before the insert so you can check that it is correct and change the mysql_query die part as[php]or die ("Couldn't execute query: ".mysql_error());[/php] and you will see any error.

Ronald
Mar 25 '08 #4
To debug this, echo the $sql statement before the insert so you can check that it is correct and change the mysql_query die part as[php]or die ("Couldn't execute query: ".mysql_error());[/php] and you will see any error.

Ronald

Thanks Ronverdonk... Its working now...
Mar 25 '08 #5
hsriat
1,654 Expert 1GB
Line 41.
Use commas between the variables.

[EDIT]
Ignore this if you already solved.
Mar 25 '08 #6
Line 41.
Use commas between the variables.

[EDIT]
Ignore this if you already solved.

You are right, there were silly mistakes in line 41. Thanks for your help;

regards

Infoseekar
Mar 25 '08 #7
hsriat
1,654 Expert 1GB
You are right, there were silly mistakes in line 41. Thanks for your help;

regards

Infoseekar
Also tell me, is the echo statement at line 5 working?
Mar 25 '08 #8
Also tell me, is the echo statement at line 5 working?
No, I have deleted that statement now..
Mar 25 '08 #9
hsriat
1,654 Expert 1GB
No, I have deleted that statement now..
Use \" when you have to send a quote to the html.
eg.<SELECT name=\"live\">
Mar 25 '08 #10
Use \" when you have to send a quote to the html.
eg.<SELECT name=\"live\">

thank you very much.. you have been very helpful..
Mar 25 '08 #11
hsriat
1,654 Expert 1GB
You are welcome. :)

Harpreet
Mar 25 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bill | last post by:
I'm having what seems to me to be an odd problem. Perhaps there is some explanation, but don't know at this point. Basically I have a form that tracks memberships and donations. The main form...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
6
by: Peter Nurse | last post by:
For reasons that are not relevant (though I explain them below *), I want, for all my users whatever privelige level, an SP which creates and inserts into a temporary table and then another SP...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.