php的知识
javascript中写php:
<script language="javascript">
function check(){
<?php
if($_SESSION["id"]){
?>
alert('您已登录!');
<?php } else {?>
alert('请登陆');
<?php } ?>
}
</script>
PHP上传文件:
<form method="post" name="form" action="" enctype="multipart/form-data">
<input name="userfile[]" type="file">
<input type="submit" value="提交">
</form>
<?php
$uploaddir = '/upload/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded./n";
} else {
echo "Possible file upload attack!/n";
}
?>