By kbahey on
I am trying to use PHP and HTML Forms from a node that is a static page, with PHP enabled.
The node displays the text fields and the button fine, but does not process them when I click on the button. It redirects to the http://mysite.com/node page for some unknown reason.
How can I get this working?
Here is some sample code I am using:
$this_script=$_SERVER["REQUEST_URI"];
print "fname=$edit['fname'] $fname lname=$edit['lname'] $lname";
if ($edit["fname"] || $edit["lname"])
{
// Capitalize the name
$full_name = ucwords ($edit["fname"] . " " . $edit["lname"]);
print "Hello! Nice to meet you <b>$full_name</b>...";
print "Glad to see that you are using my form!";
}
$form = form_textfield (t("First Name"), "fname", "", 30, 64);
$form .= form_textfield (t("Last Name"), "lname", "", 30, 64);
$form .= form_submit (t("Process"));
print form($form, "post", $this_script);
Any help appreciated.
Comments
Two suggestions to try
Try dropping the
"post"and$this_scriptparameters from the call toform()(the parameters are optional) ...or try setting
$this_scriptto$_GET['q']:Thanks, but still not working
Thanks Dries for your response.
I tried both, but neither works.
Same symptom (when the "Process" button is pressed, I get the /node page)
I also tried it with the "Process" button called "Submit", but that confused it, and caused /tracker to report some nodes with empty titles!
Any more ideas? The basic requirement here is to be able to do what I used to do in PHP from Drupal (forms, ..etc.)
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
i use this one
i use this one that i dug up on the web and modified for my own use. it does email/phone validation as well.
demo here:
http://www.avi.org/feedback
the source is here:
http://www.avi.org/feedback.phps
remember to ditch the opening/closing php tags and to also set the action value to your script's URL (only way i was able to make it work as desired).
Solved!
Here is the solution.
Thanks to all who helped.
Remember, this is dynamic PHP inside a static page, and not a module on its own.
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
How would I do that?
How would I make it so that it entered the info into a database?
Thanks
Mr Maggoo