javascript-onsubmit触发事件把表单数据发送到相关php处理问题

WBOY
發布: 2016-06-02 11:33:59
原創
936 人瀏覽過

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 {

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');

<code>echo'You are success to add dates to Mysql '.'<br>';echo 'Name :'.$name.'<br>';echo 'Score : '.$score.'<br>';echo 'Photo :'.'<img  src="'.GW_UPLOADPATH.%24st.'" alt="javascript-onsubmit触发事件把表单数据发送到相关php处理问题" >';                //第50行          echo'<p><a href="index.php">Back to index page</a></p>';</code>
登入後複製

//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.

';
<code>}//else                //第70行</code>
登入後複製

//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:
商品交易; 商品互换;


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!