2014-02-20 2 views
0

이 코드는 조금 간단 할 수도 있지만 코드가 잘못 표시되는 것은 아닙니다. 작동하지 않습니다. 제출 버튼을 클릭하면 페이지가 새로 고쳐집니다. 나는 if(isset($_POST['sub'])) 코드를 입력하지 않았다고 생각한다.제출 버튼을 누르면 페이지가 새로 고침 상태가됩니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Add Client</title> 
</head> 

<body> 
<?php 
require("dbconnect.php"); 
?> 
&nbsp; 
&nbsp; 
<form method="post"> 
<center> 
<h1>Add Client</h1> 
<table> 
<tr><td>Client Name</td><td><input name="cname" type="text" /></td></tr> 
<tr><td>Client Category</td><td><input name="cat" type="text" /></td></tr> 
<tr><td>Client Address</td><td><input name"add" type="text" /></td></tr> 
<tr><td>Client City</td><td><input name="city" type="text" /></td></tr> 
<tr><td>Contact Person</td><td><input name="cper" type="text" /></td></tr> 
<tr><td>Contact Details</td><td><input name="cdet" type="text" /></td></tr> 
<tr><td>Sales Territory</td><td> 
<?php 
$a=mysql_query("select `sales-territory-no`, `sales-territory-name` from `sales-territory`") or die(mysql_error()); 
echo"<select name='terr'>"; 
while($b=mysql_fetch_array($a)) 
{ 
    echo "<option value='".$b['sales-territory-no']."'>".$b['sales-territory-name']."</option>"; 
} 
echo "</select>"; 
?> 
</td></tr> 
<tr><td>Sales Person ID</td><td> 
<?php 
$c=mysql_query("select * from `sales`") or die(mysql_error()); 
echo"<select name='sales'>"; 
while($d=mysql_fetch_array($c)) 
{ 
    echo "<option value='".$d['sales-no']."'>".$d['firstname'].' '.$d['lastname']."</option>"; 
} 
echo "</select>"; 
?> 
</td></tr> 
</table> 
<br /> 
<input type="submit" name"sub" value="Submit" /> 
</center> 
</form> 
<?php 
if(isset($_POST['sub'])) 
{ 
    echo "<script type=\"text/javascript\">"; 
    echo "alert(\"Hello!\");"; 
    echo "</script>"; 
} 
?> 
</body> 
</html> 

답변

3
name="sub" 

당신이 제출 버튼을 코드에서 =을 놓치고 : 여기에 내 코드입니다. 이 답변은 답변으로 표시하십시오 바로 그때 인 경우이

<input type="submit" name="sub" value="Submit" /> 

<input type="submit" id="sub" value="Submit" /> or 

<input type="submit" name="sub" value="Submit" /> 

를 교체

+0

나는 '수 나는 그것을 보지 못했다고 생각하지 않는다. -___- – xjshiya

+0

때로는 두 번째 눈 쌍이 필요합니다.) – Chitowns24

관련 문제