unable to enter data in table by php

hi
i really new to programing
im unable to run mysql_query
can anybody check whats wrong with my code.[php]

Customer List <?php mysql_connect("localhost","root",""); mysql_select_db("tanisha") or die("database not found"); ?>
		</tr>
		<tr>
			<td>Sr.#</td>
			<td>auto</td>
		</tr>
		<tr>
			<td>Costomer Name</td>
			<td><input type="text" name="name"></td>
		</tr>
		<tr>
			<td>Telephone 1</td>
			<td><input type="number" name="phone1"></td>
		</tr>
		<tr>
			<td>Telephone 2</td>
			<td><input type="number" name="phone2"></td>
		</tr>
		<tr>
			<td>Address</td>
			<td><input type="text" name="address"></td>
		</tr>
		<tr>
			<td>Misc</td>
			<td><input type="text" name="misc"></td>
		</tr>
		<tr>
			<td align="center" colspan="2">
			<input type='submit' name='submit' value="submit">
			</td>
		</tr>
	</table>




<?php

mysql_connect(“localhost”,“root”,"");
mysql_select_db(“tanisha”);

if (isset($_POST['submit'])){
 $_name = $_POST['name'];
 $_phone_1 = $_POST['phone1'];
 $_phone_2 = $_POST['phone2'];
 $_address = $_POST['address'];
 $_misc = $_POST['misc'];

$query="INSERT INTO customers_list
		(name,telephon1,telephone2,address,misc) values 
		('$_name','$_phone_1','$_phone_2','$_address','$_misc')";

		if (mysql_query($query)){echo "New record created successfully";}
		else{echo "Error:";}
	//mysql_query($query) or die("database not found");
}

?>

[/php]

Costomer List

Use PDO. You shouldn’t be using mysql_ anything.

Your code is junk. Start learning here https://phpdelusions.net/pdo

I would also suggest get a stronger foundation of HTML/CSS by that I mean learn it where you are very comfortable with it. In my opinion there is no reason to put a Table in a form when other HTML tags that deal with forms can used and stylized using CSS.

Sponsor our Newsletter | Privacy Policy | Terms of Service