hey guys,
This is my first venture into php/mysql but I have found a couple of good tutorials on the net which I have been using. I've got mysql setup as localhost and the username is user, the password is pass. DB name is test and the table I'm using is called testtable. Basically all I'm trying to do at the moment is create a form in html which will submit its contents to the table. This is what I have so far:
PHP Script (test.php)
HTML<?
$username="user";
$password="pass";
$database="test";
$forename=$_POST['forename'];
$surname=$_POST['surname'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
mysql_connect(localhost,$username,$password) or die('Error connecting to mysql');
@mysql_select_db($database) or die("Unable to select database");
$query = "INSERT INTO testtable VALUES ('','$forename','$surname','$address','$postcode')";
mysql_query($query);
mysql_close();
?>
All that happens is when I click submit a blank tab opens titled test.php and thats all that happens. It's probably something stupid but I read the tutorial real close and I can't see what I have done wrong. Any help would be appreciated. Thanks<form action="test.php" method="post">
<input name="forename" type="text" /><br />
<input name="surname" type="text" /><br />
<input name="address" type="text" /><br />
<input name="postcode" type="text" /><br />
<input name="submit" type="submit" value="submit" /></form>


LinkBack URL
About LinkBacks
Reply With Quote





SCAN.care@HEXUS
