Posts: 2
Threads: 1
Joined: Sep 2014
Hello and sorry for the
simple
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
Posts: 2
Threads: 1
Joined: Sep 2014
ok ... i think i have found...
Custom URL (Slug) + exec-php
Posts: 5
Threads: 0
Joined: Oct 2014
2014-10-08, 00:30:19
(This post was last modified: 2014-10-08, 00:31:45 by beaksdale.)
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
Posts: 6,266
Threads: 181
Joined: Sep 2011
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
Posts: 5
Threads: 0
Joined: Oct 2014
(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.
Posts: 6,266
Threads: 181
Joined: Sep 2011
interesting, never even noticed that