hi guys, need your help on this.
had a form on html and saving data to mysql but it's not working here's the html code:



<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<td><form name="form1" method="post" action="insertac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<td colspan="3"><strong>Insert Data Into mySQL Database </strong></td>
<td width="71">Name</td>
<td width="6">:</td>
<td width="301"><input name="name" type="text" id="name"></td>
<td><input name="lastname" type="text" id="lastname"></td>
<td><input name="email" type="text" id="email"></td>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>



and here's the php to save to mysql which is not working, please help.

it seems the $_POST is not working but i don't have any ideas why it's not able to get data from the form.

any ideas is greatly appreciated, thanks :)


$host="localhost"; // Host name
$username="my_username"; // Mysql username
$password="my_password"; // Mysql password
$db_name="testdbx"; // Database name
$tbl_name="tblx"; // Table name

// Connect to server and select database.

    $link=mysql_connect("$host","$username", "$password");
    die("Could not connect:" .mysql_error());
    mysql_select_db("$db_name"); //here goes the database selection
    echo "Connected successfully!";

// Get values from form
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];

// Insert data into mysql
$sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')";

// if successfully insert data into database, displays message "Successful".
echo "Successful";


else {
echo "ERROR";

What output do you see?

hi pritaeas, thanks for your reply.
I just notice actually, the code works fine in Google Chrome but not in Firefox and IE.
Any ideas?
i'm using wamp on my workstation.

Strange, it is a server side script. The browser should not matter. You sure that there is nothing else interfering?

turn on error_reporting and also try to run the output of $sql directly in phpmyadmin or your MySQL application see if it inserts without error.

solution from this link: . http://www.daniweb.com/hardware-and-software/microsoft-windows/threads/30275/ie-wont-open-local-php-files-anymore
need to do some registry editing, and here's the solution from the URL above:
u need to change the .php file settings through regedit. Go to start --> run --> regedit --> under HKEY_CLASSES_ROOT, right click on .php file and select New String value. Name it Content Type. Then double click Content Type in the right panel of the window and add text/html under Value data.