I have built a form for a standard page node, using PHP filtering. I really like the ease that I could do it, but how can I collect the data being submitted? Ideally it would be thrown in the database, but I cannot seem to find the documentation for that. I really don't want to build a whole module for this, as doing so would take to long. If adding to the db is not possible (via The Drupal Way), may I specify an email address for the results to be sent? I am using 5.1.

Comments

ipwa’s picture

I would really like to be able to store information on databases from forms or get the info by mail. If anyone knows anything about the issues please post, any help would be appreciated.

Nicolas
-------------------------

ipwa’s picture

I found a way to do this, it might help you:

Make a form in HTML land create a new page in drupal using the full html option from the input format.

use: method="post" action="form_response.php"

Then make a PHP page called "form_response.php" that processes the information and sends it to an e-mail adress.

// variables can be defined in html as name for text areas and value  for radio buttons and dropdown menus
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$dropdown = $_POST['dropdown'];
$seconddropdown = $_POST['seconddropdown'];
$travelling = $_POST['travelling'];


// Validation
if(3 < strlen($name) && 3 < strlen($email) && 3 < strlen($message))
{

$email_message = <<< EMAIL
Message from websites contact form.

Name: $name
Email:$email

The message:
$message

Design Style:
$dropdown

Choices:
$seconddropdown

Travelling Method:
$travelling

EMAIL;
 


	if(mail('email@myname.com','Contact form email', $email_message))
	{
		echo "Your email has been sent, we will reply shortly. Press your back button to resume navigation.";	
	}
	else 
	{
		echo "We had a problem sending the email.";
	}
	
 
}
else
{
  echo "You did not fill in the form properly. Please use the browser's 'back' button and update the form.";	
}




change the email address to yours. upload the php page to your root drupal directory and it should work.
You can modify the php to store the variables in databases.
I know this is not the Drupal way and it is kindda dirty, but it is simple, if anyone has more ideas please reply to this post.

Nicolas
-------------------------

thenapking’s picture

I'd like to do this too. As a Drupal noob I am a bit flumoxed. I think you need to use the Forms API stuff but am having some problems with this. Do I need to install a custom module? I'm having problems browsing the modules list (the page never loads) so I cant tell if that is the case.
I pasted the code from the Quick Start example (http://api.drupal.org/api/head/file/developer/topics/forms_api.html) but it doesn't display a form or anything when i call the test_form() function. :( it returns an "unexpected $end" error.

I'm finding this rather frustrating because I know how to do what I want to do with PHP/MySQL but Drupal is just getting in the way of my standard code. :(

Help Please!

thenapking’s picture

Can anyone point us lost souls in the right direction? (and not the direction of the forms API documentation because i have read that & can't get it to work!)
thanks.