自动提交不在此脚本上工作

时间:2015-11-03 10:02:11

标签: javascript php mysql submit

我一直在实现所有javascript自动提交,但它重新加载页面并且不提交表单,请帮帮我。

<?php
ERROR_REPORTING(0);
include("../jesus/settings.php");
include("../jesus/connect.php");
#include("../jesus/header.php");
include("../jesus/func.php");

$errors=array();
if(isset($_POST["submit"]))
{
    $link=cleanvalues($_POST["link"]);
    $cat=cleanvalues($_POST["cat"]);
    $img=cleanvalues($_POST["img"]);
    $comment=cleanvalues($_POST["comment"]);
    $description=cleanvalues($_POST["description"]);
    $prefix=cleanvalues($_POST["prefix"]);
    $format=cleanvalues($_POST["format"]);
    $folder=cleanvalues($_POST["folder"]);
    $title=cleanvalues($_POST["title"]);
    if(empty($title) || strlen($title)<4)
    {
        $errors[]="Your title is too short";
    }
    if(empty($comment) || strlen($comment)<4)
    {
        $errors[]="Your comment is too short";
    }
    if(empty($cat))
    {
        $errors[]="You must select a category";
    }

    $check=mysql_num_rows(mysql_query("SELECT * FROM b_movies WHERE     title='$title'"));
    if($check>0)
    {
        $errors[]="FILE already Exists";
    }
    if(count($errors)==0)
    {
        $user=$user;
        $date=time();
        $insert=mysql_query("INSERT INTO b_movies SET `title`='$title',
    `prefix`='$prefix',
    `format`='$format', `comment`='$comment', `catid`='$cat',     `link`='$link', `img`='$img', `by`='$user', `time`='$date'");

        if(!$insert)
        {
            $msg=mysql_error();
        }
        else
        {
            $msg="Upload successful";
        }
       $query=mysql_query("SELECT * FROM b_moviescat where id=$cat");
        while($cinfo=mysql_fetch_array($query))
        {
            $cname=$cinfo["name"];
            $cbody=$cinfo["body"];
            $kellyprefix=$cinfo["name"];
            $kellyprefix=kellychiprefix($kellyprefix);

            $idd=mysql_insert_id();

            $insert=mysql_query("INSERT INTO b_updates SET prefix='$prefix',  title='$title', folder='$kellyprefix', url='$idd', description='$comment', time='$date', img='$img'");

            header("location: /cron_jobs/sitemap_updater.php?msg=$msg?$title");
            exit();
        }
    }
    else
    {
        foreach($errors as $error)
        {
            $string.="$error<br/>";
        }
        echo"<div class='msg'>$string</div>";
    }
}
echo"";
//ERRORS
echo"<form name='kellychi' id='kellychi' action='' method='POST'>
<ul><li> title<br/><input size='100' type='text' name='title' value='$name'></li>
<li><center><select name='cat'><option value='4'>Naija Movies</option>";
$query=mysql_query("SELECT * FROM b_moviescat");
while($cinfo=mysql_fetch_array($query))
{
    $cid=$cinfo["id"];
    $cname=$cinfo["name"];
    $cbody=$cinfo["body"];
    echo"<option value='$cid'>$cname</option>";
}
echo"</select></center></li><li>Link<input size='100' type='text' name='link' value='http://highspeed-cbt.com/yt/getvideo.php?videoid=".$_GET['id']."&type=Download'></li>
<li><textarea rows='7' cols='60'  name='comment'>".$dtag."

Download And Enjoy...</textarea></li>

<li><input size='100' type='text' value='http://img.youtube.com/vi/".$_GET['id']."/0.jpg' name='img'></li>
<li>prfx<input size='100' type='text' name='prefix' value='Download'></li>
<li>YT<textarea rows='7' cols='30'  name='format'><iframe width='640' height='360' src='https://www.youtube.com/embed/".$_GET['id']."'     frameborder='0' allowfullscreen></iframe></textarea></li>
<li><center></center></li></ul></form>"; ?>


<script>
    setTimeout(function() {
        document.forms[0].submit();
    }, 5000);
</script>

<?php
#echo"<div class='center'><ul><span class='style4'></span></ul></div>";
#echo"<br>";

?>

1 个答案:

答案 0 :(得分:1)

没有这样的元素:“$ _POST [”submit“]”在数组中。您需要使用其他字段名称,如:

if(isset($_POST["title"]))....

如果你把: 的print_r($ _ POST) 您将看到发送的所有帖子值。您可以选择不同的或添加隐藏值:

<input type="hidden" name="submit" value="1" />

这也可以。