473,406 Members | 2,369 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,406 software developers and data experts.

inserting into a mysql database

3
Im having a problem inserting the following data into a Mysql table, just wondering if any one has any ideas on how to get it to work. When i click the register button nothing at all happens . any one got any ideas.



<?php

$connection = mysql_connect("localhost", "root", "")
or die ("Could not connect to server");

$db = mysql_select_db('customer', $connection) or die('could not connect to DB' .mysql_error());

$query = "INSERT INTO customerdetails (custID, userName, title, password, custFirstName, custLastName, email, address1, address2, address3, country, telephone) VALUES (4,'$u', PASSWORD('$p'),'','$fn', '$ln', '$e','', '', '', '', '')";

?>

<form action="home.php"><fieldset>
<legend>Enter your information in the form below:</legend>

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

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

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

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

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

<p><b>Confirm 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>
Jan 14 '07 #1
1 1410
Expand|Select|Wrap|Line Numbers
  1. $query = "INSERT INTO customerdetails (custID, userName, title, password, custFirstName, custLastName, email, address1, address2, address3, country, telephone) VALUES (4,'$u', PASSWORD('$p'),'','$fn', '$ln', '$e','', '', '', '', '')";
it is mean that you are using
'$u' variable for userName
'$p' for title
and so on... .

Expand|Select|Wrap|Line Numbers
  1.  
  2.  <p><b>First Name:</b> <input type="text" name="custFirstName" size="15" maxlength="15" value="<?php if (isset($_POST['custFirstName'])) echo $_POST['custFirstName']; ?>" /></p>
  3.  
if you use "custFirstName" as your first name
you must declare on the query

and also the query is not send to the mysql with "mysql_query" command

example

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $query=mysql_query("insert into costumerdetails (userID, firstName, lastName) values (4, '$firstName', '$lastName')");
  3. if($query) 
  4. echo "Register Complete";
  5. ?>
  6. <form action="" method="post">
  7. First Name <input type='text' name='firstName'><br>
  8. Last Name <input type="text" name=lastName'><br>
  9. <input type='submit' values='register'>
  10. </form>
  11.  
hope usefull... .
Jan 14 '07 #2

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

Similar topics

5
by: Mechphisto | last post by:
I'm using a textarea to insert some notes into a database. It's inserting the complete result into the mySQL table including the linebreaks...and not as a visible symbol but an actual linebreak. If...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
6
by: Raqueeb Hassan | last post by:
Hello There! Have you guys tried inserting variables in mySQL tables? Do I have to use 'quote' as we had been doing to insert strings? mysql> INSERT INTO occurrence (word_id,page_id) VALUES...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
1
Ajm113
by: Ajm113 | last post by:
Ok, when I was new to this I had this problem and I bet a lot of other people did when they where new to PHP and Mysql. So this mite be your question; "Ok, no errors or warnings in mysql and php so...
0
by: gp | last post by:
I am and have been using PDO for about a year now...and have finally gotten around to solving the "DB NULL value" issues I ran into early on... I am looking for suggestions and techniques to...
1
by: djmeltdown | last post by:
I'm having trouble getting a foreach() loop to insert a record into a MySQL Database. Which I've never had any trouble before, it just seems quirky. I've tried the mysql_query statement without a...
3
by: len | last post by:
Hi All I have started a little pet project to learn python and MySQL. The project involves figuring out all the combinations for a 5 number lottery and storing the data in a MySQL file. The...
9
by: Bunty | last post by:
I am not beginer of this language. I've worked on this language for 2 or 3 months.But now i have a problem to inserting values in the database.It gives me error that DATABASE NOT SELECTED. I am...
6
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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.