farnoosh66
یک شنبه 11 تیر 1396, 20:24 عصر
سلام
دوستان یه فایل test.htmlدارم شامل:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
<form action="calc.php" method="post"><br/>
fname:<input type="text" name="fname"/><br/>
lname:<input type="text" name="lname"/>
<br/>
<input type="submit" value="register"/>
</form>
</body>
</html>
یه فایل calc.php دارم به کدهای
<html>
<head><title>An Example</title></head>
<body><div>
<?php
if ( !empty ($_POST['fname']) && !empty ($_POST['lname']) )
{
$name= $_POST['fname'];
$family= $_POST['lname'];
$coo=@mysqli_connect("localhost","root","","database1");
if (!mysqli_connect_error())
{
mysqli_query($coo,"insert into tbl1 (fname,lname) value ('".$name."','".$family."')");
mysqli_close($coo);
header("location:test.html");
}
else
{
echo 'error connect';
}
}
else
{
header("location:test.html");
}
?>
</div></body></html>
ولی وقتی submit میزنم یه صفحه خالی میاد و هیچ چیزی توی دیتابیسم ذخیره نمیشه، میشه راهنمایی کنید
دوستان یه فایل test.htmlدارم شامل:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
<form action="calc.php" method="post"><br/>
fname:<input type="text" name="fname"/><br/>
lname:<input type="text" name="lname"/>
<br/>
<input type="submit" value="register"/>
</form>
</body>
</html>
یه فایل calc.php دارم به کدهای
<html>
<head><title>An Example</title></head>
<body><div>
<?php
if ( !empty ($_POST['fname']) && !empty ($_POST['lname']) )
{
$name= $_POST['fname'];
$family= $_POST['lname'];
$coo=@mysqli_connect("localhost","root","","database1");
if (!mysqli_connect_error())
{
mysqli_query($coo,"insert into tbl1 (fname,lname) value ('".$name."','".$family."')");
mysqli_close($coo);
header("location:test.html");
}
else
{
echo 'error connect';
}
}
else
{
header("location:test.html");
}
?>
</div></body></html>
ولی وقتی submit میزنم یه صفحه خالی میاد و هیچ چیزی توی دیتابیسم ذخیره نمیشه، میشه راهنمایی کنید