데이터베이스의 테이블에 정보를 보내는 코드가 있습니다. 코드는 다음과 같습니다.내 코드가 데이터베이스에 두 번 입력합니다.
<?php
//session_start();
include("config.php");
$alertcityname = $_POST['city'];
$alerareaname = $_POST['area'];
$email = $_POST['emailid'];
$phone = $_POST['phone'];
$pref = $_POST['alert'];
$insertQuery = "insert into fir_forward (username,town,area,email,phone,pref)
values ('".$_SESSION['username']."','".$alertcityname."','".$alerareaname."',
'".$email."','".$phone."','".$pref."')";
$msg = base64_encode("Registered Successfully");
mysql_query($insertQuery) or die("error in insert record");
if(mysql_query($insertQuery))
{
header("location:updatemess.php?msg=$msg");
}
else
{
header("location:noupdatemess.php?msg=Not Registered");
}
?>
내 문제는 데이터가 두 번 입력되거나 테이블이 두꺼워지는 것입니다.
F_id username townarea phone pref email
0000000001 0000000001 [->] 0000000009 [->] 0000725954499 sms [email protected]
0000000002 0000000001 [->] 0000000009 [->] 0000725954499 sms [email protected]
0000000003 0000000003 [->] 0000000002 [->] 0000734566778 email [email protected]
0000000004 0000000003 [->] 0000000002 [->] 0000734566778 email [email protected]
친절하게 도와 주시면 오류를 표시 할 수 있습니까?
이 질문의 재미있는 부분은 질문을 읽을 때 나는 함수의 두 배를 찾아야한다는 것을 알았습니다 : mysql_query. 그것에 대해 생각해라;) – Pakspul
@ Pakkul - Lolz .. 명확하게 그것은 –