how to hide included else

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AnikiEddie
Forum Newbie
Posts: 2
Joined: Fri Nov 19, 2010 9:55 pm

how to hide included else

Post 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/
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: how to hide included else

Post by s992 »

Remove

Code: Select all

else
  echo "Error! - Key anda salah / sudah tamat tempoh!";
from key.php
AnikiEddie
Forum Newbie
Posts: 2
Joined: Fri Nov 19, 2010 9:55 pm

Re: how to hide included else

Post 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=="")
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: how to hide included else

Post 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.
Post Reply