Click to See Complete Forum and Search --> : how can i take database?
nile1483
10-07-2005, 08:40 AM
dear friends ,
i have little knowleadge of web designing(dreamwear, photoshop ,flash)
i want to make dynamic website, in first step i need to take database of customer, like
customer submit his name , e-mail address etc, and get all data submited by visitor, and i keep in into database, so when i want to send mail to particular catagery, it done only one click, how can i do it, any body have a readymade coding.
my linux server supoort php my sql
i
Webnerd
10-07-2005, 10:52 AM
First you need to know the database user name and password in order to setup the database.
BuezaWebDev
10-07-2005, 01:37 PM
When you have successfully set up your own database, you can create a customer table.
CREATE TABLE customer
(lastName VARCHAR(30)
,firstName VARCHAR(30)
,emailAddress VARCHAR(100)
);
Type that into the SQL command line OR put it into your MySQL GUI (phpMyAdmin) and it will create a specified table for your customers.
Now, with that, you can start inserting values into the table.
With your html form, all you have to do is ensure that each form element (text box) has an "id" attribute. Example:
<input type='textbox' id='name' />
In the preceding piece of code, there is an id attribute.
So, now you'll need to code the REQUEST part in PHP. Here's what I have:
<?php
/**
Basically what happens here is...
If the user sends a request to the server, it will
process the values and insert them into the db.
If the user hasn't pressed the submit button,
then output the form so that they can enter
values.
*/
if($_SERVER['REQUEST_METHOD'] == 'POST') {
//connect to the database code here
//acquire the values of the textboxes when the user submits
$username = stripslashes($_POST['username']);
$password = stripslashes($_POST['password']);
$result = mysql_query("INSERT INTO customer(lastName, firstName, emailAddress) VALUES('$lastName', '$firstName', '$email'");
echo "Thank you for submitting.\n";
} else {
//output the form
?>
<form action='form.php' method='post' name='submitApplication'>
<input type='text' id='lastName' /><br />
<input type='text' id='firstName' /><br />
<input type='text' id='email' /><br />
<input type='submit' id='submit' value='Login' />
<input type='reset' id='clear' value='Clear' />
</form>
<?php } ?>
If you need anymore clarification, don't hesitate to ask. This is just a simple example. I'm pretty sure everyone here would lend a hand on how to go about this.