<a href="#" class="button">Etiam posuere</a> </div>
我怎样才能使这个调用 php 使用?因为我希望它在 php 中执行此操作:
所以按钮正在读取这个 php,或者它可以做和这个一样的事情。
if (isset($_POST['do1'])){
$klasse = $_POST['antall'];
$klasse = strtolower($klasse);
$dato = $_POST['dato'];
$fag = $_POST['fag'];
$tema = $_POST['tema'];
$info = $_POST['info'];
if ($info == "") {
$info = "ukjent";
}
if ($tema == "") {
$tema = "ukjent";
}
$exists = file_exists("proveload/prove$klasse.txt");
if(!$exists) {
$ourFileName = "proveload/prove$klasse.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("Noe er feil med filen");
$stringData = "$dato $fag ($tema , $info).";
fwrite($ourFileHandle, $stringData);
fclose($ourFileHandle);
echo "lagde filen prove$klasse.txt ";
} else {
$file = "proveload/prove$klasse.txt";
$data = "$dato $fag ($tema , $info).\n";
$fp = fopen($file, "a", "\n") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");
}
}
索引.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900" rel="stylesheet" />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />
<link href="fonts.css" rel="stylesheet" type="text/css" media="all" />
<!--[if IE 6]><link href="default_ie6.css" rel="stylesheet" type="text/css" /><![endif]-->
</head>
<body>
<div id="header-wrapper">
<div id="header" class="container">
<div id="menu">
<ul>
<li class="current_page_item">
<a href="#" accesskey="1" title="">
Legg inn prøver
</a>
</li>
</ul>
</div>
<div id="logo">
<h1>
<a href="#"></a>
</h1>
</div>
</div>
</div>
<div id="wrapper1">
<div id="welcome" class="container">
<div class="title">
<h2>Få oversikt over prøvene du skal ha!</h2>
<span class="byline">
Her kan du legge inn prøvene du skal ha. Disse vil bli sortert i riktig rekkefølge, og den nermeste prøven du skal ha vil bli vist i programmet
</span>
</div>
<div class="content">
<tr>
<td class=mainTxt colspan=2><br></td>
</tr>
<tr>
<td class=mainTxt><br>klasse: (feks 3pbc)<br></td>
<td class=mainTxt><input type=text name=antall><br></td>
</tr>
<tr>
<td class=mainTxt><br>fag:<br></td>
<td class=mainTxt><input type=text name=fag><br></td>
</tr>
<tr>
<td class=mainTxt><br>dato (feks 24.09.2013)<br>:</td>
<td class=mainTxt><input type=text name=dato><br></td>
</tr>
<tr>
<td class=mainTxt><br>tema:<br></td>
<td class=mainTxt><input type=text name=tema><br></td>
</tr>
<tr>
<td class=mainTxt><br>har du programfag? hvis ja, hvilket?:<br></td>
<td class=mainTxt><input type=text value=ingen name=programfag><br></td>
</tr>
<tr>
<td class=mainTxt><br>annet:<br></td>
<td class=mainTxt><input type=text name=info><br></td>
</tr>
</div>
</div>
</div>
</body>
</html>
<?
print <<<ENDHTML
<form method="post" action="">
<tr>
<td class=mainTxt colspan=2><input type="submit" align="center" value="ferdig" name="do1"></td>
</tr>
</form>
ENDHTML;
<?
<?
if (isset($_POST['do1'])){
$klasse = $_POST['antall'];
$klasse = strtolower($klasse);
$dato = $_POST['dato'];
$fag = $_POST['fag'];
$tema = $_POST['tema'];
$info = $_POST['info'];
if ($info == "") {
$info = "ukjent";
}
if ($tema == "") {
$tema = "ukjent";
}
$exists = file_exists("proveload/prove$klasse.txt");
if(!$exists) {
$ourFileName = "proveload/prove$klasse.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("Noe er feil med filen");
$stringData = "$dato $fag ($tema , $info).";
fwrite($ourFileHandle, $stringData);
fclose($ourFileHandle);
echo "lagde filen prove$klasse.txt ";
} else {
$file = "proveload/prove$klasse.txt";
$data = "$dato $fag ($tema , $info).\n";
$fp = fopen($file, "a", "\n") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");
}
}
?>