cookie 函数 session mail 数据库连接 xml - php会话
来源:自学PHP网
时间:2014-11-27 22:01 作者:
阅读:次
[导读] ?php 写cookiesetcookie(user,wang70937,time()+60); sessionsession_start();if(isset($_session[ 39;views 39;]))$_session[ 39;views 39;]=$_session[ 39;views 39;]+1;else$_sess...
cookie 函数 session mail 数据库连接 xml
- <?php
-
- setcookie("user", "wang70937", time()+60);
-
- session_start();
-
- if(isset($_session['views']))
- $_session['views']=$_session['views']+1;
-
- else
- $_session['views']=1;
- echo "session: views=". $_session['views']."<br />";
- ?>
-
- <script >
- function show(){
- alert("asdf");
- }
- </script>
-
- <html>
- <title>php测试页面 </title>
- <head><script src="clienthint.js"></script></head>
- <body>
- <?php
-
- echo "<br />"."[******输出******]"."<br />";
- echo "hello world!"."<br />";
- $a = "php";
- $b = "language";
- echo $a." ".$b."<br />";
-
-
- echo "<br />"."[******数组******]"."<br />";
- $arr = array("abcde", "fghijk", "lmnopq");
- foreach($arr as $value)
- {
- echo $value."<br />";
- }
-
-
- echo "<br />"."[******函数******]"."<br />";
- function funa($a, $b){
- echo "函数参数:".$a.", ".$b;
- return "ret_value";
- }
- $ret = funa(123, "param");
- echo "函数返回值:".$ret."<br />";
-
-
- echo "<br />"."[******表单******]"."<br />";
- ?>
- <form action="form.php" method="post">
- name: <input type="text" name="name" />
- age: <input type="text" name="age" />
- <input type="submit" />
- </form>
-
- <?php echo "<br />";
-
- echo "<br />"."[******上传文件******]"."<br />";
- ?>
- <form action="upload_file.php" method="post"
- enctype="multipart/form-data">
- <label for="file">filename:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="submit" />
- </form>
-
- <?php
-
- echo "<br />"."[******session******]"."<br />";
-
-
- echo "pageviews=". $_session['views'];
- ?>
- <br />
-
- <!--
- <?php
-
-
- ?>
-
- <?php
-
- echo "<br />"."[******发送邮件******]"."<br />";
-
- $to = "wang70937@163.com";
- $subject = "test mail";
- $message = "hello! this is a simple email message.";
- $from = "wang70937@gmail.com";
- $headers = "from: $from";
- mail($to,$subject,$message,$headers);
- echo "mail sent."."<br />";
- ?>
-
- <?php
-
- echo "<br />"."[******mysql数据库******]"."<br />";
- $con = mysql_connect("localhost","root","1");
- if (!$con)
- {
- die('could not connect: ' . mysql_error());
- }
- else
- echo "连接mysql成功!"."<br />";
- mysql_select_db("bbs", $con);
- mysql_query("set names gbk");
-
- $tablecount = mysql_query("show tables");
- while($table = mysql_fetch_array($tablecount))
- {
-
- $tablename = $table[0];
- $sql = "select * from ".$tablename;
- $result = mysql_query($sql);
-
- echo "<br />表:[".$tablename."]<br />";
-
- $filedcount = mysql_num_fields($result);
-
- $recordcount = mysql_num_rows($result);
-
- echo "sql[".$sql."] 记录条数:".$recordcount."<br />";
-
- if($filedcount > 0 )
- {
- echo "<table border='1'>;
- <tr>
- <th>记录序号</th>";
- for($index=0; $index<$filedcount; $index++)
- {
-
- $filedname = mysql_fetch_field($result);
- echo "<th>$filedname->name</th>";
- }
- echo "</tr>";
- $no = 0;
- while($row = mysql_fetch_array($result))
- {
- $no = $no + 1;
- echo "<tr>";
- echo "<td>" . $no . "</td>";
- for($index=0; $index<$filedcount; $index++)
- {
- echo "<td>" . $row[$index] . "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
-
- }
- }
-
-
-
-
- mysql_close($con);
- ?>
-
- <?php
-
- echo "<br />"."********xml解析********"."<br />";
-
-
-
-
-
-
-
-
-
- $xml = simplexml_load_file("note.xml");
-
- echo $xml->getname() . "<br />";
-
- foreach($xml->children() as $child)
- {
- echo $child->getname() . ": " . $child . "<br />";
- }
- ?>
-
- <?php
-
- echo "<br />"."*******ajax*******"."<br />";
- ?>
- <form>
- first name:
- <input type="text" id="txt1"
-
- onkeyup="show()">
- </form>
- <p>suggestions: <span id="txthint"></span></p>
- </body>
- </html>
|