|
|
|
สอบถาม " Auto Submit Javascript Timeout " ไม่ทำงานครับ |
|
|
|
|
|
|
|
จากการค้นหามาแล้ว ก่อนจะมาถาม ><" เด๊วกลัวโดนว่า " ทำไมไม่ลองหาข้อมูลก่อน "
https://www.thaicreate.com/php/forum/024080.html
ผมเลยลองเอาไปประยุกต์ใช้ กับ Script ของผม แต่ปรากฏว่ามันไม่ Auto Submit ให้
ยังไงรบกวนท่านที่ชำนาญ ตรวจสอบความผิดพลาดที่ครับผม
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript">
function AutoSubmit()
{
setTimeout("frmMain.submit();",1000)
// 1 Second = 1000
}
</script>
</head>
<body onLoad="AutoSubmit();">
<?php
include("function_config_connection.php");
if(isset($_POST['submit']))
{
function GetImg($host,$link)
{
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr (error number $errno)
\n";
} else {
$out = "GET $link HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$out .= "Accept-Language: en-us,en;q=0.5\r\n";
$out .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$out .= "Keep-Alive: 300\r\n";
$out .= "\r\n";
fwrite($fp, $out);
$contents='';
while (!feof($fp)) {
$contents.= fgets($fp, 1024);
}
fclose($fp);
return $contents;
}
}
//function to get image with CURL
function GetImageFromUrl($link)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch,CURLOPT_URL,$link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
return $result;
}
$contents= file_get_contents($_POST['url']);
$savefile = fopen('images/'.$_POST["id"].'.png', 'w');
fwrite($savefile, $contents);
fclose($savefile);
$storeDelete = mysql_query("DELETE FROM `item_db3` WHERE id = '".$_POST["id"]."' LIMIT 1");
echo "<script>window.location='index.php';</script>";
} else {
$strSQL = mysql_query("SELECT * FROM `item_db3` ORDER by id ASC");
$Result = mysql_fetch_array($strSQL);
?>
<div style="margin-left:auto; margin-right:auto; margin-top:400px; text-align:center;">
<form name="frmMain" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="url" value="http://www.divine-pride.de/images/items/item/<?=$Result['id'];?>.png">
<input type="hidden" name="id" value="<?=$Result['id'];?>" />
<input name="submit" id="submit" type="submit" value="ITEM ID : <?=$Result['id'];?>">
</form>
</div>
<?
}
?>
</body>
</html>
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2012-06-13 16:58:00 |
By :
blackedition |
View :
1871 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้ละครับ
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body onLoad="AutoSubmit();">
<?php
include("function_config_connection.php");
if(isset($_POST['submit']))
{
function GetImg($host,$link)
{
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr (error number $errno)
\n";
} else {
$out = "GET $link HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$out .= "Accept-Language: en-us,en;q=0.5\r\n";
$out .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$out .= "Keep-Alive: 300\r\n";
$out .= "\r\n";
fwrite($fp, $out);
$contents='';
while (!feof($fp)) {
$contents.= fgets($fp, 1024);
}
fclose($fp);
return $contents;
}
}
//function to get image with CURL
function GetImageFromUrl($link)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch,CURLOPT_URL,$link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
return $result;
}
$contents= file_get_contents($_POST['url']);
$savefile = fopen('images/'.$_POST["id"].'.png', 'w');
fwrite($savefile, $contents);
fclose($savefile);
$storeDelete = mysql_query("DELETE FROM `item_db3` WHERE id = '".$_POST["id"]."' LIMIT 1");
echo "<script>window.location='index.php';</script>";
} else {
$strSQL = mysql_query("SELECT * FROM `item_db3` ORDER by id ASC");
$Result = mysql_fetch_array($strSQL);
?>
<div style="margin-left:auto; margin-right:auto; margin-top:400px; text-align:center;">
<form name="myForm" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="url" value="http://www.divine-pride.de/images/items/item/<?=$Result['id'];?>.png">
<input type="hidden" name="id" value="<?=$Result['id'];?>" />
<input name="submit" id="submit" type="submit" value="ITEM ID : <?=$Result['id'];?>">
</form>
<script language="JavaScript"><!--
setTimeout('document.myForm.submit.click()',3000);
//--></script>
</div>
<?
}
?>
</body>
</html>
เอาไว้สำหรับคนที่ Search หา ><"
|
ประวัติการแก้ไข 2012-06-13 17:15:40
|
|
|
|
Date :
2012-06-13 17:09:27 |
By :
blackedition |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|