Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP] If the above statements is true, show this statement.

Experienced Elementalist
Joined
Mar 22, 2008
Messages
297
Reaction score
0
I'm working on a little script (habbo online loader creator) and i'm pretty mutch done except for one thing.

This is my page view.php
PHP:
$hname = $_GET['hotelname'];
$ip = $_GET['ip'];
$port = $_GET['port'];
$texts = $_GET['texts'];
$vars = $_GET['vars'];
$dcr = $_GET['dcr'];
$loader = $_GET['loader'];
$back = "index.php";
// HERE THE HNAME CONTROLS STARTS!

if (
 !$hname || empty($hname)
)
{
   echo "<font class=text>The <font class=error>hotel name</font> is empty!<br>";
}
// HERE THE HNAME CONTROLS END

// HERE THE IP CONTROLS STARTS!

if (
 !$ip || empty($ip)
)
{
   echo "<font class=text>The <font class=error>IP</font> is empty!<br>";
}
// HERE THE IP CONTROLS ENDS!
// HERE THE PORT CONTROLS STARTS!

 if (
 !$port || empty($port)
)
{
   echo "<font class=text>The <font class=error>port</font> is empty!<br>
   ";
}
// HERE THE PORT CONTROLS ENDS!
// HERE THE TEXTS CONTROLS STARTS!

if (
 !$texts || empty($texts)
)
{
   echo "<font class=text>The <font class=error>texts</font> url is empty!<br>";
}
// HERE THE TEXTS CONTROLS END
// HERE THE VARS CONTROLS STARTS!

if (
 !$vars || empty($vars)
)
{
   echo "<font class=text>The <font class=error>vars url</font> is empty!<br>";
}
// HERE THE VARS CONTROLS END
// HERE THE DCR CONTROLS STARTS!

if (
 !$dcr || empty($dcr)
)
{
   echo "<font class=text>The <font class=error>DCR url</font> is empty!<br>";
}
// HERE THE DCR CONTROLS END


else {
    // If none of the above statements is correct.

echo "<font class=text>And your loader is done, all you have to do i copy and paste!<br><br>";
echo "<font class=text2>Code:</font>";

echo "<table class=code width=650 valign=top>
<td class=code td valign=top>
<font class=text2>
<br><html>
<br><head>
<br><title><font class=info>$hname</font></title>
<br><base target=_blank>
<br></head>
<br><body bgcolor=#000000 topmargin=0 link=#FFFFFF vlink=#FFFFFF alink=#FFFFFF>
<br><div align=center>
<br><param name=src value=>
<br><param name=swRemote value=swSaveEnabled=true swVolume=true swRestart=false swPausePlay=false swFastForward=false swTitle=<font class=info>$hname</font> swContextMenu=true>
<br><param name=swStretchStyle value=none>
<br><param name=swText value=>
<br><param name=bgColor value=#000000>
<br><param name=sw6 value=external.texts.txt=<font class=info>$texts</font>>
<br><param name=sw2 value=connection.info.host=<font class=info>$ip</font>;connection.info.port=<font class=info>$port</font>>
<br><param name=sw4 value=connection.mus.host=;connection.mus.port=30 001>
<br><param name=sw3 value=client.reload.url=<font class=info>$loader</font>>
<br><param name=sw1 value=site.url=<font class=info>$loader</font>;url.prefix=<font class=info>$hname</font>>
<br><param name=sw5 value=external.variables.txt=<font class=info>$vars</font>>
<br><embed src=<font class=info>$dcr</font> bgColor=#000000 width=720 height=540 align=middle swRemote=swSaveEnabled=true swVolume=true swRestart=false swPausePlay=false swFastForward=false swTitle=massivewake swContextMenu=true swStretchStyle=none swText= type=application/x-director pluginspage=http://www.macromedia.com/shockwave/download/
<br>sw6=external.texts.txt=<font class=info>$texts</font>
<br>sw2=connection.info.host=<font class=info>$ip</font>;connection.info.port=<font class=info>$port</font>
<br>sw4=connection.mus.host=;connection.mus.port=30001
<br>sw3=client.reload.url=<font class=info>$dcr</font>
<br>sw1=site.url=<font class=info>$loader</font>;url.prefix=<font class=info>$hname</font>
<br>sw5=external.variables.txt=<font class=info>$vars</font>>
<br></div>
<br></body>
<br></html>

</td>
</table>";
echo "<br><font class=text>(All your info is marked <font class=info>red</font>!)</font>.";
echo "<br><br><a href=index.php><font class=text>Make a new loader (back to index)</a>.";
}



?>

And i wan't to add another if before the else, but i wan't it to show only if one of the above statements are true, (the if will containt a back button).
But i have no idea how to do that. Any help from you guys?
 
Experienced Elementalist
Joined
Mar 22, 2008
Messages
297
Reaction score
0
You'll have to explain more, since i am a beginner in php.

Can anybody just explain?
 
Last edited:
Newbie Spellweaver
Joined
Feb 10, 2008
Messages
30
Reaction score
0
I had a similar problem I guess you could say. Daevius helped me with this. What you do is set a boolean. You define it earlier in your script. $valid = true;

PHP:
<?
/* Define the Boolean here */
$valid = false
/* Just Putting this so you notice it */
$hname = $_GET['hotelname'];
$ip = $_GET['ip'];
$port = $_GET['port'];
$texts = $_GET['texts'];
$vars = $_GET['vars'];
$dcr = $_GET['dcr'];
$loader = $_GET['loader'];
$back = "index.php";
// HERE THE HNAME CONTROLS STARTS!

if (!$hname || empty($hname))
{
   echo "<font class=text>The <font class=error>hotel name</font> is empty!<br>";
   $valid = false;
}
// HERE THE HNAME CONTROLS END

// HERE THE IP CONTROLS STARTS!

if (!$ip || empty($ip))
{
   echo "<font class=text>The <font class=error>IP</font> is empty!<br>";
   $valid = false
}
// HERE THE IP CONTROLS ENDS!
// HERE THE PORT CONTROLS STARTS!

 if (!$port || empty($port))
{
   echo "<font class=text>The <font class=error>port</font> is empty!<br>";
   $valid = flase;
}
// HERE THE PORT CONTROLS ENDS!
// HERE THE TEXTS CONTROLS STARTS!

if (
 !$texts || empty($texts)
)
{
   echo "<font class=text>The <font class=error>texts</font> url is empty!<br>";
   $valid = false;
}
// HERE THE TEXTS CONTROLS END
// HERE THE VARS CONTROLS STARTS!

if (
 !$vars || empty($vars)
)
{
   echo "<font class=text>The <font class=error>vars url</font> is empty!<br>";
   $valid = false;
}
// HERE THE VARS CONTROLS END
// HERE THE DCR CONTROLS STARTS!

if (
 !$dcr || empty($dcr)
)
{
   echo "<font class=text>The <font class=error>DCR url</font> is empty!<br>";
   $valid = false;
}
// HERE THE DCR CONTROLS END


if($valid)
{
    // If none of the above statements is correct.

echo "<font class=text>And your loader is done, all you have to do i copy and paste!<br><br>";
echo "<font class=text2>Code:</font>";

echo "<table class=code width=650 valign=top>
<td class=code td valign=top>
<font class=text2>
<br><html>
<br><head>
<br><title><font class=info>$hname</font></title>
<br><base target=_blank>
<br></head>
<br><body bgcolor=#000000 topmargin=0 link=#FFFFFF vlink=#FFFFFF alink=#FFFFFF>
<br><div align=center>
<br><param name=src value=>
<br><param name=swRemote value=swSaveEnabled=true swVolume=true swRestart=false swPausePlay=false swFastForward=false swTitle=<font class=info>$hname</font> swContextMenu=true>
<br><param name=swStretchStyle value=none>
<br><param name=swText value=>
<br><param name=bgColor value=#000000>
<br><param name=sw6 value=external.texts.txt=<font class=info>$texts</font>>
<br><param name=sw2 value=connection.info.host=<font class=info>$ip</font>;connection.info.port=<font class=info>$port</font>>
<br><param name=sw4 value=connection.mus.host=;connection.mus.port=30 001>
<br><param name=sw3 value=client.reload.url=<font class=info>$loader</font>>
<br><param name=sw1 value=site.url=<font class=info>$loader</font>;url.prefix=<font class=info>$hname</font>>
<br><param name=sw5 value=external.variables.txt=<font class=info>$vars</font>>
<br><embed src=<font class=info>$dcr</font> bgColor=#000000 width=720 height=540 align=middle swRemote=swSaveEnabled=true swVolume=true swRestart=false swPausePlay=false swFastForward=false swTitle=massivewake swContextMenu=true swStretchStyle=none swText= type=application/x-director pluginspage=http://www.macromedia.com/shockwave/download/
<br>sw6=external.texts.txt=<font class=info>$texts</font>
<br>sw2=connection.info.host=<font class=info>$ip</font>;connection.info.port=<font class=info>$port</font>
<br>sw4=connection.mus.host=;connection.mus.port=30001
<br>sw3=client.reload.url=<font class=info>$dcr</font>
<br>sw1=site.url=<font class=info>$loader</font>;url.prefix=<font class=info>$hname</font>
<br>sw5=external.variables.txt=<font class=info>$vars</font>>
<br></div>
<br></body>
<br></html>

</td>
</table>";
echo "<br><font class=text>(All your info is marked <font class=info>red</font>!)</font>.";
echo "<br><br><a href=index.php><font class=text>Make a new loader (back to index)</a>.";
}
?>

Hopefully this works x_x Good luck.
 
Custom Title Activated
Loyal Member
Joined
Feb 27, 2004
Messages
1,378
Reaction score
50
PHP:
$check['hname'] = $_GET['hotelname'];
$check['ip'] = $_GET['ip'];
$check['port'] = $_GET['port'];
$check['texts'] = $_GET['texts'];
$check['vars'] = $_GET['vars'];
$check['dcr'] = $_GET['dcr'];
$check['loader'] = $_GET['loader'];
$check = false;

foreach ($check as $key => $k) {
    if (!$k || empty($k)  {
echo "<font class=text>The <font class=error>".$key."</font> is empty!<br>";
   $check = false;
   } else {
// do ur stuff here
   }
}

if ($valid == false) {
 //form here
}

basically does the same thing.. u can even make it shorter by just looping thru the GET variables
 
Joined
Jul 26, 2006
Messages
3,634
Reaction score
1,007
I usually do something like;
PHP:
<?php
if ($_GET['blabla'] == '')
{
$msg = "Blabla is empty!";
$c = 1;
}
//more if's

if ($c != 1)
{
//form
}

//in the html, just put <?=$msg;? > (without the space) where you want the message to display.
?>
 
Newbie Spellweaver
Joined
Sep 28, 2007
Messages
64
Reaction score
0
There is no reason to even convert the $_GET into $variable['whatever'], You can simply do:

PHP:
<?php
$error = FALSE;
foreach ($_GET as $key => $var)
{
	if(!strlen($var) OR eregi('[^a-z0-9]', $var))
	{
		echo '<font class="text">The <font class="error">' . $key . '</font> field is empty or contains non alphanumeric characters!';
		echo '<br />';
		$error = TRUE;
	}
}

if($error == TRUE)
{
	echo 'Errors encountered are listed above.';
}
?>
 
Last edited:
Back
Top