javascript-onsubmit觸發事件把表單資料發送到相關php處理問題

來源:互聯網
上載者:User
關鍵字 php javascript
phpjavascript

問題詳情:onsubmit觸發事件把表單資料發送到相關php處理但是如何避免資料有問題時也會觸發事件呢?

function dosubmit(){ window.open('num3.php?cf='+window.form.cf.value+'&cf1='+window.form.cf1.value); }


require_once('appvars.php');
require_once('connectvars.php');

if(isset($_POST['submit'])){ //第10行

$name=$_POST['name'];
$score=$_POST['score'];
$st=$_FILES['st']['name'];
$st_type=$_FILES['st']['type'];
$st_size=$_FILES['st']['size'];
$output_form=false;

if( empty($name) || empty($score) || empty($st))
{
echo'Something is wrong !
';
$output_form=true;
}
//第20行
else{

if( (($st_type=='image/gif')||($st_type=='image/jpeg')||($st_type=='image/pjeg')||($st_type=='image/png')) && ($st_size >0) && ($st_size <=MAX_FILE_SIZE) )
{

if($_FILES['st']['error']==0){

$target=GW_UPLOADPATH .$st;
//第30行

if(move_uploaded_file($_FILES['st']['tmp_name'],$target)){

$dbc=mysqli_connect(HOST,USER,PASSWORD,NAME);

$st=$_FILES['st']['name'];
$query="INSERT INTO b (date,st,score,name)".
"VALUES(NOW(),'$st','$score','$name')";
//第40行

mysqli_query($dbc,$query)
or die('UU');

echo'You are success to add dates to Mysql '.'
';echo 'Name :'.$name.'
';echo 'Score : '.$score.'
';echo 'Photo :'.''; //第50行 echo'

Back to index page

';

//clear the score datas
$name="";
$score="";
$st="";

mysqli_close($dbc);

}//if(move_uploaded_f

else
{
echo $_FILES['st']['error'];
echo'
檔案沒有移動成功 !!';//第60行

}

}//if($_FILES['st']['error']

else
echo'There is something wrong to upload the file ! Plese upload it agian.';

}//if(($st_type=='image/gif'

else echo'

The screen pic must be a GIF,JPEG, or PNG image and the file '.'size must fit '.'(MAX_FILE_SIZE/1024)'.'KB.

';
}//else                //第70行

//Try to delete the temporary screen shot image file.

@unlink($_FILES['st']['tmp_name']);

}else $output_form=true;

if($output_form){
?>

Your name:
Your score:
Your Photo:
商品交易; 商品互換;


  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.