0

いくつかのファイルをデータベースにアップロードしていますが、シリアル コードが入力されたときに問題のファイルを取得できる PHP フォームが必要です。データベースに 2 つのエントリがありますが、PHP フォームはそれを 0 行として返し続けます。提供されたヘルプに感謝します。繰り返しますが、php を知っている人の仲間入りをしようとしているので、助けてくれてありがとう。

フォームは常に、「データが見つかりません。シリアル コードを確認して、間違って入力していないことを確認してください。コードが正しい場合は、ウェブサイト管理者にメールを送信してください」という行がないかのように返します。

<?php
if( $_POST )
{
$username="st*****";
$password="*****";
    $con = mysqli_connect("storycodes.db.10339998.hostedresource.com",$username,$password);

    if (!$con)
    {
        die('Could not connect: ' . mysql_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);

}
?>

データベース エントリ: 列は (これが役立つ場合): コード、電子メール、ビデオ、およびストーリーです。

b2348-5dfae-73c0c-57685 s* * @yahoo.com ../story_files/story.txt

90a93-785e4-03cad-a18d5 w*@ * *.com ../video_files/story.txt ../story_files/story.txt

コードはこのフォームで投稿されています:

<link href="/CSS/CSS.css" rel="stylesheet" type="text/css">

<p align="center"><span class="linkText"><a href="/index.html">Home</a> <a href="/contact-us.php">Contact Us</a> <a href="/payments.html">Payments</a></span></p>
<p align="center">&nbsp;</p>
<p align="center"><span class="headingText"><img alt="legendmaker - makes legends: banner" width="728" height="90" /></span></p>
<p align="center">&nbsp;</p>
<div align="center" class="headingText">Enter Your Serial Code Below To Continue Your Adventure!</div>

<p>&nbsp;</p>
<form name="form1" method="post" action="/scripts/stories.php">
  <label>
  <div align="center"><span class="formText">Your Serial Code:
    <input name="codeInput" type="text" id="codeInput" size="23" maxlength="23">
  </span></div>
  </label>
  <div align="center"><span class="formText">
  </span></div>
  <span class="formText"><label> 
  <div align="center"><br>
  </div>
  </label>
  </span>
  <label>
  <div align="center"><br>
      <input type="submit" name="submit" id="submit" value="Submit">
  </div>
  </label>
</form>

<p>&nbsp;</p>
<p class="headingText">&nbsp;</p>
<p align="center" class="headingText">Can't find your code?</p>
<p align="center" class="paragraphText">Request an email with your code below.</p>
<form name="form2" method="post" action="/scripts/code_request.php">
  <label class="formText">
  <div align="center">Email:
    <input type="text" name="email" id="email">
  </div>
  </label>
  <p align="center">
    <label>
    <input type="submit" name="submit2" id="submit2" value="Submit">
    </label>
  </p>
</form>
<p>&nbsp;</p>

HTMLについては気にしないでください。助けてくれてありがとう。私はすべて混乱しました!

4

2 に答える 2

1
$query = "SELECT story,video FROM `storycodes` WHERE `code` = 'code'";

$不在です。

これを試して:

$query = "SELECT story,video FROM `storycodes` WHERE `code` = '$code'";

またはこれ:

$query = "SELECT story,video FROM `storycodes` WHERE `code` = '".$code."'";
于 2013-02-07T03:21:36.743 に答える
1
$query = "SELECT story,video FROM `storycodes` WHERE `code` = 'code'";

この行のどこで変数 $code を参照していますか?...

ヒント -$記号が重要です...

于 2013-02-07T03:17:41.927 に答える