Page 1 of 1

how to hide included else

Posted: Fri Nov 19, 2010 9:56 pm
by AnikiEddie
index.php

Code: Select all

<center>
<h2>~[BestPunya.Com & Zone KrozerR]~</h2>
<br>
<form action="index.php" method="post">
Key: <input type="text" name="key" />
<input type="submit" value="DOWNLOAD!" />
</form>
<? include "key.php"; ?>
</center>
key.php

Code: Select all

<? include "xxx.php";?>
<?php echo $_POST["key"]; ?>
<br>
<br>
<?php
$key=$_POST["key"];

if ($key=="$keyone")
  echo "<a href='index.php'>Try again?</a><br/>Title : $titleone<br>Season : $seasonsone<br>Episode : $episodesone<br>File Size : $sizeone<br><br><a href='$linkone'>DOWNLOAD NOW!</a>";

elseif ($key=="$keytwo")
  echo "<a href='index.php'>Try again?</a><br/>Title : $titletwo<br>Season : $seasonstwo<br>Episode : $episodestwo<br>File Size : $sizetwo<br><br><a href='$linktwo'>DOWNLOAD NOW!</a>";
  
else
  echo "Error! - Key anda salah / sudah tamat tempoh!";
?>
</center>
xxx.php

Code: Select all

<?
//01
$titleone='Title 1 goes here';
$seasonsone='-';
$episodesone='02';
$sizeone='5MB';
$linkone='http://xxxxxxxxxxxxxxxxxxxxxxxxx';
$keyone='xxxx-xxxx-xxxx-xxxxx-xxxx';

//02
$titletwo='title 2 goes here';
$seasonstwo='-';
$episodestwo='-';
$sizetwo='10MB';
$linktwo='http://xxxxxxxxxxxxxxxxxxxxxxxxx';
$keytwo='yyyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy';
?>
How do I hide the sentence "Error! - Key anda salah / sudah tamat tempoh!" on page index.php before submit the key?
Demo : http://server000.bestpunya.com/

Re: how to hide included else

Posted: Sat Nov 20, 2010 2:37 am
by s992
Remove

Code: Select all

else
  echo "Error! - Key anda salah / sudah tamat tempoh!";
from key.php

Re: how to hide included else

Posted: Sat Nov 20, 2010 5:12 am
by AnikiEddie
but, if i remove

Code: Select all

else
  echo "Error! - Key anda salah / sudah tamat tempoh!";
there will be no result when someone submit the wrong key.. any other way?

-------------------------

update : already solve this problem by use a blank for

Code: Select all

if ($key=="")

Re: how to hide included else

Posted: Sat Nov 20, 2010 7:06 am
by Celauran
AnikiEddie wrote: update : already solve this problem by use a blank for

Code: Select all

if ($key=="")
You could also wrap the whole block in

Code: Select all

if (!empty($_POST))
{
  // Whatever
}
so that it is only evaluated after the form is submitted.