Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION html form with post method
#1
Hello and sorry for the Smile simple Smile question. I am a newbie so ... Can anyone suggest me how to create my own form? I have code :
Code:
<form id="form" name="form_name" action="#" method="POST">
<input type=radio name="sth" value=1 >1 <br>
<input type=radio name="sth" value=2 >2 <br>
<input type=radio name="sth" value=3 >3 <br>
<input type=submit value="GO 1" onclick="document.getElementById('form').action='go1.php';" >
<input type=submit value="GO 2" onclick="document.getElementById('form').action='go2.php';" >
...
And how to create go1.php and go2.php files in GS ?
Where can I use '$_POST['sth']' in GS?
Do I have to create a plugin?
Any ideas, tutorials or manual guides ?

Thx
Reply
#2
ok ... i think i have found...
Custom URL (Slug) + exec-php
Reply
#3
I am having a problem along these lines, I have a simple contact form on my website that I am unable to process as when I submit it the $_POST array is empty. Here is the code for the form
Code:
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'] . "?id=" . return_page_slug()); ?>" enctype="text/plain" method="post">
    Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    Comment: <input type="text" name="comment"><br>
    <input type="submit">
</form>
So the form links to itself where I have PHP code in the template to deal with it, but it doesn't run as the $_POST array reports back as empty. I've checked as many website as I can to try and diagnose the issue but no luck. I have other websites running on my server that don't use GetSimple (yet) with forms that function using POST so I don't think it's generally server configuration. I've looked at the SERVER array and after trying to submit the form it has the request method set to POST instead of GET. I know you can't send GET and POST data at the same time but you can append some GET data to a POST request (allowing me to get back to the correct page slug with the form on). I've checked my GetSimple installation but everything is set to green on the support screen.
I'm at a loss as to what the problem is can anyone help me? Cheers
Reply
#4
My guess is there is a redirect occurring before your code runs, so you are losing the data.

learn how to use your browsers development tools to inspect the headers etc.
chrome F12
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
(2014-10-08, 00:48:42)shawn_a Wrote: My guess is there is a redirect occurring before your code runs, so you are losing the data.

learn how to use your browsers development tools to inspect the headers etc.
chrome F12

Thanks for the suggestion. I've looked at Chrome's developer tools and while I couldn't work out if it was redirecting I did notice that it wasn't being treated as form data but request payload, which was because I was using enctype text/plain for the form instead of the default.
Reply
#6
interesting, never even noticed that
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)