PHP Save info from textbox script

bladee4r

Regular Member
Joined
May 3, 2021
Messages
390
Reaction score
359
I had a script like this before, but I lost it. I'm not too good with PHP, can someone provide me a simple script that just collects user input from a text box upon "submit button"?
Even if that submit button is a redirect to another page?

I tried it myself, but I can't figure out how to activate the <a href> at the same time as "saving" the user textbox input into a server-side txt file.
I just want the script to append whatever is added into the text box, to a server-side txt file. Can anyone help me out? I'm not doing web2.0 otherwise I would use something from there.
 
To get what is submitted and use is just $_POST['fieldname'];

So like this
//form page
<Form method=post action=processingpage.php>
<input type=text name=textbox>
<input type=submit name=submit value=submit>

//processingpage.php
<?php
$text=$_POST['textbox'];
do what you want with variable $text

Hope that helps
 
To get what is submitted and use is just $_POST['fieldname'];

So like this
//form page
<Form method=post action=processingpage.php>
<input type=text name=textbox>
<input type=submit name=submit value=submit>

//processingpage.php
<?php
$text=$_POST['textbox'];
do what you want with variable $text

Hope that helps
Okay, yeah that looks familiar I think my last one was quite similar.
How would I get that button to also redirect to a new link (other page on website)
Could I include a redirect in processingpage.php ?
 
It's the "action" attribute of the form that defines which script/page will be loaded if you press the submit button.

1637921572332.png


Another approach would be to use JS to send the data with AJAX to a backend script, and then redirect to another page.
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock