ok with HTML // learning PHP
trying the most SIMPLE tests for my self
made at DB using phpMyAdmin installed on my PC (WinXP)
c:\wamp\www = localhost
(ie i put my index.html in that folder and 'surf' to localhost and all is fine )
I put this file in same directory (eg my2.html)
and surf to [http://localhost/my2.html ]
and it looks ok
here is html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form action="process.php" method="post"> Your Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Location: <input type="text" name = "location"><br> <input type="submit" value="Submit"> </form> </body> </html>
and here is the code for process.php
<head> <title>Untitled</title> </head> <body> <?php $name=$_POST['name']; $email=$_POST['email']; $location=$_POST['location']; MySQL_connect("localhost:/MySQL/data/test1", "root", "")or die ('I cannot connect to the database because: ' . MySQL_error()); MySQL_select_db("test1"); MySQL_query("INSERT INTO `test1table` VALUES ('$name', '$email', '$location')"); Print "Your information has been successfully added to the database."; ?> </body> </html>
it also appears ok in browser
I get this as echo on screen (ie NOT the error message)
Your information has been successfully added to the database.
I am guessing the problem is in the HOST field above in the 'msql_connect' line
and yes - there is a DB called "test1" and a table called "test1table.frm"
which is a folder called test1 which is in the data folder (as above)
I have been reading tutorials for hours
they say DB "locations" (and something about 'socks' )
so = what is syntax for my location???
2nd question - as this is not working = why does it show the 'success' echo when I submit the data?
(I open the DB using phpMyAdmin and there are no new data rows)