IKA Processing Equipment - Debt Consolidation - Number Ones - Debt Consolidation - Online Advertising

PDA

View Full Version : Whats wrong with this code?


Loget
Jun 2nd 2009, 10:28 am
<html>
<body>
<div style="background-color:green;width:200px;">

<b>Config Grabber BETA</b>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Are you ready?: <input name="go" size="0">
<input type="submit" name="submit" value="Go">
</form>
<?php
$rook = $_POST['go'];
if ($rook > 0);
{


$file = includes/config.php;
$result = file_get_contents($file);
}
echo "$result";
else {
echo "Something went wrong....";
}
?>
</div>
</body>
</html>

I just want it to get the file and echo its contents :confused:

Liam_Tatton
Jun 2nd 2009, 10:38 am
Do you get any errors when you run the code?

Loget
Jun 2nd 2009, 10:47 am
I just get a blank page.

Fr0Gs
Jun 2nd 2009, 11:41 am
if ($rook > 0); there shouldent be a ; after that

KalvinB
Jun 2nd 2009, 4:31 pm
$rook = isset($_POST['go']) ? 1 : 0;


The form element "go" is never given a value so the value of $_POST['go'] will be an empty string which in PHP land is equal to 0.


<input name="go" size="0" value="1">


Will also work.

ezprint2008
Jun 2nd 2009, 11:11 pm
a lot of that code is wrong.
Weak HTML form code, weak PHP code ..
youre basically trying to put together a script and you dont know HTML forms or PHP that well .. keep learning.

the two posts above are right. you have no value in your "name" field
<input type="text" name="go" value="1234">


theres no ; after the rook variable where you should have a

and your includes/config.php
include('config.php');

keep learning.

kishore415
Jun 2nd 2009, 11:41 pm
a lot of that code is wrong.
Weak HTML form code, weak PHP code ..
youre basically trying to put together a script and you dont know HTML forms or PHP that well .. keep learning.

the two posts above are right. you have no value in your "name" field
<input type="text" name="go" value="1234">


theres no ; after the rook variable where you should have a


this is correct as you said..


and your includes/config.php
include'config.php';


His intension is not to include files..but read the file from includes folder..what he has written is correct

and you echo "$result";

should go inside if loop ...it shoould not be outisde of if loop before "else" statement...

All the best..dont hesitate to more questions...

Spawny
Jun 3rd 2009, 12:00 am
you should echo the result variable ' $result ' inside the if statement

Loget
Jun 5th 2009, 1:21 am
<html>
<body>
<div style="background-color:green;width:200px;">

<b>Config Grabber BETA</b>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Are you ready?: <input name="go" size="0" value="1"">
<input type="submit" name="submit" value="Go">
</form>
<?php
$rook = isset($_POST['go']) ? 1 : 0;
if ($rook > 0)
{


$file = includes/config.php;
$result = file_get_contents($file);
echo $result;

}

else {
echo "Something went wrong....";
}
?>
</div>
</body>
</html>

Is that alright?