View Single Post
  #7 (permalink)  
Old Jun 14th, 2006, 15:53
mikes mikes is offline
New Member
Join Date: Jun 2006
Location: Birmingham
Age: 29
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: My SQL/PHP - phpmyadmin

Using myphpadmin I have done the following under database name 'test'

Table Person has been created.
SQL query:CREATE TABLE `Person` ( `FirstName` VARCHAR( 15 ) NOT NULL ,
`LastName` VARCHAR( 15 ) NOT NULL ,
`Age` INT NOT NULL
) ENGINE = MYISAM ;


now i've added the form to a webpage on my server using the following code

<form action="insert_db.php" method="POST">Enter your Firstname: <input type="text" name="firstname" />Enter your Lastname: <input type="text" name="lastname" />Enter your Age: <input type="text" name="age" /><input type="submit" /></form>

Where insert_db.php, should i ammend this to the database name I am using?

On the furstname, lastname and age fields are the first letters case sensitive?

Then to show the form the route to the table i use the following?

$con = mysql_connect("localhost","###username###","###pas sword###");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person(firstname,lastname,age)VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "Success!";

Please feel free to show me any errors

Last edited by sypher; Jun 14th, 2006 at 19:13.
Reply With Quote