Php 试图限制表单提交的数量

Php 试图限制表单提交的数量,php,mysql,Php,Mysql,因此,本质上,登录用户只能提交一次他们的首选项,然后从表中编辑它们 if(isset($_POST['userPrefSave'])){ $studetnPrefId=$_POST['studentPrefId']; $studentId=$_POST['studentId']; $result= limitUserPref($studentPrefId,$studentId); //print_r($result); if(isset($result)

因此,本质上,登录用户只能提交一次他们的首选项,然后从表中编辑它们

if(isset($_POST['userPrefSave'])){
    $studetnPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];

    $result= limitUserPref($studentPrefId,$studentId);
    //print_r($result);
    if(isset($result)< 1){
    $studentPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];
    $english=$_POST['english'];
    $math=$_POST['math'];
    $science=$_POST['science'];
    $history=$_POST['history'];
    $oralComm=$_POST['oralComm'];
    $pe=$_POST['pe'];
    $health=$_POST['health'];
    $art=$_POST['art'];
    $electives=$_POST['electives'];
    setUserPref($studentPrefId, $studentId, $english, $math, $science, $history, $oralComm, $pe, $health, $art, $electives);

    header ("Location: userpref.php");
}
}
功能^^^


我不知道怎么了,提前谢谢你看来你的支票不对。 isset()将确定变量是否已设置且不为NULL

关于php isset的更多信息

您正在检查的内容将始终是真实的
if(isset($result)<1){

试试下面的方法

if(isset($_POST['userPrefSave'])){
    $studetnPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];

    $result= limitUserPref($studentPrefId,$studentId);
    //print_r($result);
    if(count($result) < 1){
    $studentPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];
    $english=$_POST['english'];
    $math=$_POST['math'];
    $science=$_POST['science'];
    $history=$_POST['history'];
    $oralComm=$_POST['oralComm'];
    $pe=$_POST['pe'];
    $health=$_POST['health'];
    $art=$_POST['art'];
    $electives=$_POST['electives'];
    setUserPref($studentPrefId, $studentId, $english, $math, $science,     $history, $oralComm, $pe, $health, $art, $electives);

header ("Location: userpref.php");
}
}
if(isset($\u POST['userPrefSave'])){
$studetnPrefId=$\u POST['studentPrefId'];
$studentId=$_POST['studentId'];
$result=limitUserPref($studentPrefId,$studentId);
//打印(结果);
如果(计数($result)<1){
$studentPrefId=$\u POST['studentPrefId'];
$studentId=$_POST['studentId'];
$english=$_POST['english'];
$math=$_POST['math'];
$science=$_POST['science'];
$history=$_POST['history'];
$oralComm=$_POST['oralComm'];
$pe=$_POST['pe'];
$health=$_POST['health'];
$art=$_POST['art'];
$electionals=$_POST[‘electionals’];
setUserPref($studentPrefId、$studentId、$english、$math、$science、$history、$oralComm、$pe、$health、$art、$elections);
标题(“位置:userpref.php”);
}
}

可能是重复的,我已经读过,但它没有完全满足我的需要我玩了一些,但我无法达到我的需要,而且我不希望页面死亡,因为用户在该页面上有一个表,他们可以编辑信息存储您可以检查$result变量,它在第一次提交时返回什么,第二个呢?你可能需要尝试使用count($result),无论我在哪里打印它都没有发生任何事情。那么它可能在第一次加载时为空,请使用count($result)尝试代码Instedi让它做了一些事情,但它加载到了我的用户控制器中,而不是返回到userpref页面。出现了一些语法错误,但它们被发现并编辑了。您知道如何防止它加载到控制器中吗?
if(isset($_POST['userPrefSave'])){
    $studetnPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];

    $result= limitUserPref($studentPrefId,$studentId);
    //print_r($result);
    if(count($result) < 1){
    $studentPrefId=$_POST['studentPrefId'];
    $studentId=$_POST['studentId'];
    $english=$_POST['english'];
    $math=$_POST['math'];
    $science=$_POST['science'];
    $history=$_POST['history'];
    $oralComm=$_POST['oralComm'];
    $pe=$_POST['pe'];
    $health=$_POST['health'];
    $art=$_POST['art'];
    $electives=$_POST['electives'];
    setUserPref($studentPrefId, $studentId, $english, $math, $science,     $history, $oralComm, $pe, $health, $art, $electives);

header ("Location: userpref.php");
}
}