Jump to content

What am i doing wrong?


cry of war

Recommended Posts

i tried to get this code to load but it doesnt want to for some odd reason anyone know why?

 

<?php
$info = $_POST["info"];
$id = $_POST["id"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form action="<?php echo $PHP_SELF;?>" method="post">
PLEASE CLICK INSIDE OF THE SGW SPY LOG AREA AND PRESS CTRL+A THEN CTRL+C THEN CLICK IN THE TEXT AREA BELOW WHERE IT SAYS "INSERT HERE".
<textarea rows="20" cols="20" name="info" wrap="physical">INSERT HERE</textarea><br />
ENTER ID: <INPUT TYPE="TEXT" name="id" value="id">INPUT ID HERE</INPUT>
<input type="submit" value="submit" name="submit"><input>
</form>
<?PHP
} else {
$wordChunks = explode(" ", $info);
for($i = 0; $i < count($info); $i++){
echo "Piece $i = $wordChunks[$i] <br />";
}
}
?>
</body>
</html>

Link to comment
Share on other sites

Register_globals is probably off (the $PHP_SELF should be $_SERVER['PHP_SELF']

 

Make sure www.php.net/error_reporting is set to E_ALL and display_errors is on to make sure you are getting an error message if there is one.

Link to comment
Share on other sites

You have some invalid HTML issues, input tags do not have closing tags. So removeclosing tags for inputs (</input>)

 

Also your for loop needs to be this:

for($i = 0; $i <= count($info); $i++){

Notice the equals sign added after the the less than sign. With the way you have it PHP will never get to the last item within loop, for example it will only loop 7 times if there was 8 items within the array.

 

Working code:

<?php
// if page is not submitted to itself echo the form
if (!isset($_POST['submit']))
{
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
PLEASE CLICK INSIDE OF THE SGW SPY LOG AREA AND PRESS CTRL+A THEN CTRL+C THEN CLICK IN THE
TEXT AREA BELOW WHERE IT SAYS "INSERT HERE".
<textarea rows="20" cols="20" name="info" wrap="physical">INSERT HERE</textarea><br />
ENTER ID: <INPUT TYPE="TEXT" name="id" value="INPUT ID HERE" /><br />
<input type="submit" value="submit" name="submit" />
</form>
<?PHP
}
else
{
    $info = $_POST['info'];
    $id   = $_POST['id'];

    $wordChunks = explode(" ", $info);

<?php
// if page is not submitted to itself echo the form
if (!isset($_POST['submit']))
{
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
PLEASE CLICK INSIDE OF THE SGW SPY LOG AREA AND PRESS CTRL+A THEN CTRL+C THEN CLICK IN THE
TEXT AREA BELOW WHERE IT SAYS "INSERT HERE".
<textarea rows="20" cols="20" name="info" wrap="physical">INSERT HERE</textarea><br />
ENTER ID: <INPUT TYPE="TEXT" name="id" value="INPUT ID HERE" /><br />
<input type="submit" value="submit" name="submit" />
</form>
<?PHP
}
else
{
    $info = $_POST['info'];
    $id   = $_POST['id'];

    $wordChunks = explode(" ", $info);

    for($i = 0; $i <= count($info); $i++)
    {
    echo "Piece $i = $wordChunks[$i] <br />";
    }
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.