Pokémon TCG: Sword and Shield—Brilliant Stars

php $POST ?

Muscovy Level X

New Member
I've been looking at php lately and I've been stumped when it comes to posting type actions.
I can do and understand actions that submit variables in the url and parrot them back in some way, but I can't find any documentation on how to actualy do something more like a forum post.
Can anyone explain it?
 
A good website I'd suggest is this - If you're looking for $_POST, specifically. W3Schools has a very good breakdown of just about every function available to you in PHP, most of which have very good and very basic examples to show you how to use them.

If you are looking more towards creating your own forums, that will take a lot more work than a simple $_POST. I found a website you could use that will give you the basic idea of what you will be needing to look for. Use this code as a guideline only, make sure you spend the time to dissect the code and learn what each piece does and how it works.
 
$_POST is usually used in forms where you don't want it shown in the url.

So like you have your form or whatever, maybe it will look like this:

<form action="page_with_post.php" method="POST">
<input type="text" name="name_of_text_box"><BR><input type="submit" name = "name_of_submit_button">

page_with_post.php

this code's in PHP:
if($_POST['name_of_submit_button']){
$text_from_post = $_POST['name_of_text_box'];
//do more stuff like use MySQL to save it and whatnot
}

If that helps at all...
 
I may as well specify that this is for something like editing the text of a page. I suppose it's not really like a forum with coding, bu the $_POST function as I understand it isn't what I'm looking for.
 
The way I understand it, correct me if I'm wrong, you'd like to be able to type into a box of some sort, hit the Submit button and the text on a certain page would be updated with the new text.

In order to do something such as that, it will be something along the lines of a forum post. The idea to this is to update/add text to the database in the correct section of the database on one page, and then draw that same information up on another page.
 
Yep, with the exception of adding a password, but I think I understand that component.
Basicly, it's that the only post-style actions I know give variables that show up in the text where requested and in the url.
Like, name and age forms, where on the destination page you script for the variables of name and age to appear with the text. However, it'll have a url along the lines of pagename&varName&varAge or similar.
 
Yep, with the exception of adding a password, but I think I understand that component.
Basicly, it's that the only post-style actions I know give variables that show up in the text where requested and in the url.
Like, name and age forms, where on the destination page you script for the variables of name and age to appear with the text. However, it'll have a url along the lines of pagename&varName&varAge or similar.

You need to change your <form> tag.

<form method="post">

The "get" method (which is the default) encodes the form data in the URL.
 
Ok, I'll try that out.

Back to back posts merged. The following information has been added:

I got it to work, but navaagting away from the page will make the inputs clear.

I used
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

and

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!

I'll try using $_REQUEST, it seems to be what I'm after.

Edit: Request worked just like post. Shouldn't it be permanent (until the new text is inserted)?
 
Last edited:
Back
Top