我有2個程序welcome.php和form.jsp。我打算通過用戶形式使用odbc將值插入到SQL數據庫中。我已經使用form.jsp創建了一個用戶窗體。使用welcome.php插入行。而插入不插入重複的值,以便檢查while循環中的條件。當if語句正在工作時,由於exit()語句,它完全從程序中出來。在執行完退出後得到空白頁面。但我需要保留回到用戶窗體或控件應該去form.jsp,以便我應該得到用戶窗體輸入的細節沒有給空白page.how我可以這樣做嗎?控制應該去if語句中的其他程序使用php
$query1="select * from company";
$result1 = odbc_exec($connect, $query1);
while(odbc_fetch_row($result1)){
$compname[$index] = odbc_result($result1, 1);
$empname[$index] = odbc_result($result1, 2);
if($compname[$index]==$_POST['cname'])
{
echo "<script> alert(\"compname Exists\") </script>";
exit();
//exit("<script> alert(\"compname Exists\") </script>");
}
if($empname[$index]==$_POST['ename'])
{
echo "<script> alert(\"empname Exists\") </script>";
exit();
}
}
$query=("INSERT INTO dbo.urllink(cname,ename) VALUES ('$_POST[cname]','$_POST[ename]') ");
$result = odbc_exec($connect, $query);
echo "<script> alert(\"Row Inserted\") </script>";
?>
請注意,您還可以利用會話數據避免需要通過URL傳回大量數據。 –
@威爾比克福德,好點。 – Cyntech
我應該爲abc寫函數嗎? – user998461