473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting into a mysql database

3 New Member
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.ph p"><fieldset >
<legend>Enter your information in the form below:</legend>

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

<p><b>Last Name:</b> <input type="text" name="custLastN ame" 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 1429
treecool
6 New Member
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 "custFirstN ame" as your first name
you must declare on the query

and also the query is not send to the mysql with "mysql_quer y" 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
2272
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 I select the fireld in mySQL at a command prompt, the results take an inordinate amount of space from all the linebreaks. I tried nl2br() before it goes into the INSERT, but all that does is ADD <br /> to the data but it still have linebreaks...
13
9310
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 three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
6
2625
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 ($word_id,$page_id); ERROR 1054: Unknown column '$word_id' in 'field list'
14
2907
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 statement. I first connect to the database... self.con = MySQLdb.connect(user=username, passwd =password) self.cursor = self.con.cursor() self.cursor.execute("SET max_error_count=0")
1
1671
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 why isn't the script entering info into my row?". Well to awnser your question most servers that you pay for monthly or own will have a anti mysql injection attack. So it will not allow the injection to enter in your database for your protection...
0
1768
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 deal with inserting DB NULL values into my MySQL 5.x DB Tables....I am running PHP 5.2.x on BSD 6.x with Apache 2.2.x.... As mentioned I am writing all my web apps using the PDO extension to connect and operate on the database. I realized early...
1
3037
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 preceeding variable as well. System information Server Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.3 Time: 12/07/2007 01:20:06 PM PHP PHP Version: 5.2.3 Safe Mode activated: no PHP Memory...
3
2636
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 file looks like this; +----------+---------------------+------+-----+--------- +----------------+ | Field | Type | Null | Key | Default |
9
1565
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 using wampserver.Please help me for this prob.
6
1899
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
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.