Dreameaver, mysql, php my admin and 1and1 web hosting

Hello,
I am new to php & mysql but experienced with dreamweaver, HTML and CSS.
I am wondering if anyone out there can help me?

I have created 2 x fields in dreamweaver to cllect data. One for name and one for email address.

I want the user to enter there name and email address and that data to populate a database in my php admin / mysql.
I use 1and1 hosting and apparently I cannot use remote access from dreamweaver.

I believe this can be done and I need a php script to perform this?

I would really appreciate any help with this?

Regards
Kev

First you need to make sure your form is going to the php script. So make a form with html like this:
[php]
Your Name:

E-mail:

[/php] Then you need to make a process.php file: [php]<? $name=$_POST['name']; $email=$_POST['email']; $location=$_POST['location']; mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error()); mysql_query("INSERT INTO `data` VALUES ('$name', '$email')"); Print "Your information has been successfully added to the database."; ?> [/php] you fill in your information for the "hostadress" "username" "password" and "database name"

Hope that helps!!

Thanks egmike.
Unfortunately I still cannot get this to work.
Is it me been an idot?

Do I do anything with the PHP script execpt load it to the server?

I have pointed to it in dreamweaver. When I load the page it just points to the PHP like it is a normal html link.

Thanks again,
Kev

You just have to put the html form in a page (make sure the form action is going to the php script in this case process.php) The php script just needs to be uploaded to the main public_html folder on the server.

I’m just going to ask to make sure, do you already have the database and table set up on phpmyadmin?

I forgot to tell you in the last message that you need to change: data to the name of the table you want the data to go to:
[php]mysql_query(“INSERT INTO data VALUES (’$name’, ‘$email’)”); [/php]

I hope that helps

Thanks again for the reply.
I hadn’t changed the ‘data’ bit in the script.

Unfortunately still the same. When click submit the php script just opens in the same browser.

The php script is in the same folder as all the HTML documents.

I have set up the database and are able to manually add details.

I’m wondering if it’s a 1and1 issue?

Thanks again Kev

Sponsor our Newsletter | Privacy Policy | Terms of Service