Home  • Programming • PHP
My host port is localhost:8080, database faiza. My php code fails to insert data. There is code:
<?php
if(isset($_POST["btnSubmit"])){
	$name		=$_POST["txtName"];
	$mail		=$_POST["txtEmail"];
	$phone		=$_POST["txtPhone"];
	
	$con = mysql_connect("localhost:8080","root","");	
	mysql_select_db("faiza", $con);
	$sql="insert into contact(name,email,phone) values ('$name','$mail','$phone')";
	mysql_query($sql);
	mysql_close($con);
	
}
?>
<div style="height:300px; margin:0 auto; width:80em;">
	<body>
    <form action="#" method="post">
    	<table>
            <tr>
                <td>Name*</td>
                <td><input type="text" id="txtName"/></td>
            </tr>
            <tr>
                <td>Email Address*</td>
                <td><input type="text" id="txtEmail"/></td>
            </tr>
            <tr>
                <td>Phone*</td>
                <td><input type="text" id="txtPhone"/></td>
            </tr>          
             <tr>
                <td colspan="2" align="center"><input type="submit" id="btnSubmit" value="Submit"/></td>
            </tr>
         </table>
       </form>
    </body>
</div>

Comments 11


vai
$db=new MYSQLi("loclahost","root","","faiza");
[code]
$db=new MYSQLi("loclahost","root","","faiza");   query("insert into contact(name,email,phone) values ('$name','$mail','$phone')");
vai
$db=new MYSQLi("localhost","root","","faiza");   $db->query("insert into contact(name,email,phone) values ('$name','$mail','$phone')"); 
ai code ta use korte paren
Thanks @ Abdullah Al Mamun. My problem was that I fail to find out this code error.
[code][/code]
[code]
$con = mysql_connect("localhost","root","");	
	mysql_select_db("faiza", $con);
	$sql="insert into contact(name,email,phone) values ('$name','$mail','$phone')";
	mysql_query($sql);
	mysql_close($con);
$con = mysql_connect("localhost","root","");	
	mysql_select_db("faiza", $con);
	$sql="insert into contact(name,email,phone) values ('$name','$mail','$phone')";
	mysql_query($sql);
	mysql_close($con);
ভাই আমি sQl খুব ভাল জানিনা Mysqli একটু জানি
Thank @ Abdullah Al Mamun. Bhai, I failed to find out this php code error. As far, I remember, I worked like this code before. I worked on your code. It's work. Thanks again for help me.
Wellcome
About Author
Md. Saydul Alam
Copyright © 2025. Powered by Intellect Software Ltd