このような機能をどのように実行しますか?
<input name="downvid2" type="button" id="downvid2" onclick="
<?php
header('Content-disposition: attachment; filename=file.pdf');
header('Content-type: application/pdf');
readfile('file.pdf');
?>" value="Download Story" />
フォームを作成して送信しますが、いくつかのPHP変数の値が必要であり、ページを移動するときにそれらを失いたくありません。
完全なコードは次のとおりです。
<title>Legendmaker - Your Legendmaker Adventure Starring You:</title>
<?php
if( $_POST )
{
$username="***";
$password="*****";
$con = mysqli_connect("storycodes.db.10339998.hostedresource.com",$username,$password);
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db($con, "storycodes");
$code = $_POST['codeInput'];
$code = mysqli_escape_string($con, htmlspecialchars($code)); //May not acually need htmlspecialchars
$query = "SELECT story,video FROM `storycodes` WHERE `code` = '$code'";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result))
{
$row = mysqli_fetch_assoc($result);
mysqli_free_result($result);
extract($row);
echo $story . $video;
}
else
{
echo "No Data Found. Please check your serial code to ensure that you have not incorrectly entered it. If the code is correct please email the website administrator for further assistance";
}
mysqli_close($con);
}
?>
<div align="center">
<p><span class="linkText"><a href="/index.html">Home</a> <a href="/contact-us.php">Contact Us</a> <a href="/payments.html">Products</a><a href="/products.html"></a></span> </p>
<p> </p>
<h2 class="headingText"><img alt="legendmaker - makes legends: banner" width="728" height="90" /></h2>
<h2 class="headingText"> </h2>
<h2 class="headingText">Your story</h2>
</div>
<p> </p>
<label>
<input type="button" name="downvid" id="downvid" value="Download Video" />
</label>
<input name="downvid2" type="button" id="downvid2" onclick="
<?php
header('Content-disposition: attachment; filename=file.pdf');
header('Content-type: application/pdf');
readfile('file.pdf');
?>" value="Download Story" />
前のフォームにシリアルコードを入力した人だけがアクセスできるように、ファイルをWebにアクセスできないようにしたいので、ファイルPHPに関連するすべての処理を行う必要があると思います。