DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   HELP: created dreamweaver form, but how do i get results from form? (http://www.daniweb.com/forums/thread35030.html)

maxtaz Nov 8th, 2005 2:43 pm
HELP: created dreamweaver form, but how do i get results from form?
 
up to 3am last night, any help appreciated!!! have a html form created in dreamweaver. want users to complete their details on a form. do not need a dynamic page or sql d.base as only one way traffic. i just want to receive date in either email or excel format. my hoster works with cgi and php, but not asp. have read php is better, but do i need to creat a php script and do i create it in dreamweaver or do i create it thru the cpanel of my web hoster... really confused, know that i need to create this 'interpreter' prob using php, but don't know where its sits. could i cut and paste a php script and save as a .php in dreamweaver, if so how will this send the data, name-value pairs to my web hoster email or a specifiec excel d.base. wot do i type in my ACTION box!!!!! answers on a postcard please.......... thank u xxxxxxxx :confused:

msteudel Nov 9th, 2005 3:58 pm
Re: HELP: created dreamweaver form, but how do i get results from form?
 
This should be fairly easy for you to do. We'll use a two page method as that's pretty easy to do.

1. Point your form at your soon to be created php script. You should have some like below in your form, method and action are the important part right now.

e.g. [PHP]<form name="register" method="post" action="process.php">[/PHP]

2. Create a page called process.php

note: if you see something like <words> change everything including the brackets.

[PHP]<?php

// this sets up your email headers, just change the email address
$headers = "From: "<youremailaddress@yourdomain.com>\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";

// this emails you the results of the form
mail( "<youremail@yourdomain.com>", "<subject>", print_r( $_POST, true),"$headers">

// this will redriect the user somewhere away from this page
header("location: http://<whereyouwanttheusertobedirected>");

?>[/PHP]

So above it would print out something like:

Array ( [name] => Mark [email] => mark@email.com [buttons] => Array ( [submit] => Submit ) )

Ugly but gets the job done. Once you get the above working you could try formating the message differently:
[PHP]
$message = "

Name: ".$_POST[name]."<br />
Email: ".$_POST[email]."<br />";

[/PHP]

Then you would replace the the print_r( $_POST ) with $message in your mail() command, like below
[PHP]mail( "<youremail@yourdomain.com>", "<subject>", $message ,"$headers">[/PHP]
Now it would print out like:

Name: Mark
Email: mark@email.com

You could get even more completed by adding html commands to format text, add tables, whatever your imagination comes up with.

Have fun!

Mark

msteudel Nov 9th, 2005 4:00 pm
Re: HELP: created dreamweaver form, but how do i get results from form?
 
I noticed the this forum stipped out my backslashes, so wherever you see "rn" in the headers area there needs to be a backslash, eg. \r\n

maxtaz Nov 11th, 2005 1:15 pm
Re: HELP: created dreamweaver form, but how do i get results from form?
 
gosh ur an angel..im going to try it right away... someone also mentioned executed php script so will explore too...thank u a million times... (big smiley face)

msteudel Nov 11th, 2005 1:19 pm
Re: HELP: created dreamweaver form, but how do i get results from form?
 
Quote:

Originally Posted by maxtaz
gosh ur an angel..im going to try it right away... someone also mentioned executed php script so will explore too...thank u a million times... (big smiley face)

NP ask if you have questions.

vgnarc@freshrus Oct 21st, 2006 9:23 pm
Re: HELP: created dreamweaver form, but how do i get results from form?
 
i tried to use this scrpit and i resulted in error.please i would like to kno any correction that can be made in my code. the form page is www.freshrus.com/form.html
then i tried to make the
www.freshrus.com/process.php

if u can read the code and help me out it would be greatly spprcisted


All times are GMT -4. The time now is 8:03 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC