0

I've been trying to create a simple little blog for something I want to add in my school assignment. All I want it to do is to output my input in the order it is entered (like a wall on facebook).

My code is:

<?php
    //other form that does the password

    $pass = $_POST['pass'];
    $blog =$_POST['blog'];
?>

<form method="post"
      action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <textarea placeholder="Write Something, Me."
              autofocus
              required
              autocomplete="off"
              name="blog"></textarea>
    <br />
    <input type="password"
           placeholder="Password"
           autocomplete="off"
           name="pass"
           method="post" />
    <input type="submit"
           name="submit"
           value="Submit">
</form>

<?php
    If ($pass=="pass") {

    echo 'Access Confirmed<br>';

    echo $blog;
    echo '<br/><br/>';
    echo $blog;
    echo '<br/><br/>';
    echo $blog;

    } else { 

    echo 'Wrong password or invalid blog entry. Try again Noob.<br>';

    }
?>

I need to be able to call $blog as an array and output multiples datas as they are being entered (like in facebook). But as you can tell it's just printing the same thing over and over again. Also I don't want it do delete all the inputs if the "Password" (can't really call it secure) is entered incorrectly. I still want to be able to see the previous inputs.

I've tried many things, but none seem to work for me.

If this is unclear and you still have questions, please ask. Thanks.

1
  • 1
    Sidenote: Even though it's for your own use, don't store passwords in plain text. Commented Feb 13, 2014 at 1:28

1 Answer 1

1

I think you're a long ways from where you want to be with this. I'll get you started by saying that if you have an array, you can't simply use echo to print it, you need to enumerate through the array and print out the pieces that you're interested in.

foreach ($blog as $value) {
    echo $value;
}

Start here and work your way up: http://www.php.net/manual/en/control-structures.foreach.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.