PHP? ??? ? ?? ?? ??? ? ? ?? ??? ?????.
? ??? ?? ??? ?? ???? ??? ?? ?? ??? ???? ????
?? ????? <form> ??? ???? ???? ????
?? ??? ???? ??? ???? ??????? ?????. SQL ?? ?? INSERT INTO
?? ??? ? ??? ?????.
<td align="right" class="td_bg"> <input type="hidden" name="action" value="insert"> <input type="submit" name="button" id="button" value="提交" /> </td>
?? ???? $_POST ???? ?????. ? ? ??? ??????? ????? SQL ? INSERT INTO? ?????.
<?php if($_POST['action']=="insert"){ $SQL = "INSERT INTO yx_books (name,price,uploadtime,type,total,leave_number) values('".$_POST['name']."','".$_POST['price']."','".$_POST['uptime']."','".$_POST['type']."','".$_POST['total']."','".$_POST['total']."')"; $arr=mysqli_query($link,$sql); if ($arr){ echo "<script language=javascript>alert('添加成功!');window.location='add.php'</script>"; } else{ echo "<script>alert('添加失敗');history.go(-1);</script>"; } } ?>
?? <from> ??? onSubmit ?? ???? ???? ???.
<form id="myform" name="myform" method="post" action="" onsubmit="return myform_Validator(this)">
onSubmit ?? ???? ???? <javascript>? ???? ??? ? ??? ?? ? ????. ?? ??.
<script type="text/javascript"> function myform_Validator(theForm) { if (theForm.name.value == "") { alert("請輸入書名。"); theForm.name.focus(); return (false); } if (theForm.price.value == "") { alert("請輸入書名價(jià)格。"); theForm.price.focus(); return (false); } if (theForm.type.value == "") { alert("請輸入書名所屬類別。"); theForm.type.focus(); return (false); } return (true); } </script>