Need help with FORM/CGI. Simple!? request!?

P

Peter Lozzi

::Sigh::

I am going to take a risk here, and probably be yelled at, etc... But
I am pulling my hair out, and I am QUITE CERTAIN the key to my problem
is right there, and in my grasp...

I am a novice using Macromedia Dreamweaver to design a website. I am
100% self taught, and think I have an okay grasp on nested tables and
putting together some coherent graphics.

I created a form. The form is located here:

http://www.vacavillemultimedia.com/contact.html

All I want to do is take the information that the user puts in the
fields and send it to me via email.

THAT'S IT. THAT'S ALL I AM ASKING.

I have spent TWO WEEKS scouring the ends of the earth for a solution,
and I know it is RIGHT UNDER MY NOSE.

Here's what I know so far...

I need to use the <POST> method to have the HTML page send the info to
a CGI script that resides on the server, right? That CGI script does
*something* to the info, and viola, it ends up in my inbox, no? THATS
ALL I AM ASKING.

On the remote root level of my site (the same level as the index page)
is a folder (that was put there by the hosting company) with the label
CGI. I would imagine this is where I put the CGI script?

I have serched google 20 different ways to find information, a
tutorial, etc, on how to do this, and it's the ONE THING I CANNOT seem
to accomplish. My Dreamweaver book (all 900 pages) just says to
contact the web host for more information. The web host kinda chuckled
and said, "It's easy, what's the problem?" then never followed up (at
least not yet.)

Like I said, this CANT be this hard, right? I know one of you can do
this in your sleep! PLEASE tell me what piece of the puzzle I am
missing... Maybe take a look at the page, and see how simple it would
probably be?!

Thanks in advance for any assistance you can offer...

Pete
 
C

Christopher Finke

Peter Lozzi said:
I created a form. The form is located here:

http://www.vacavillemultimedia.com/contact.html

All I want to do is take the information that the user puts in the fields
and send it to me via email.

THAT'S IT. THAT'S ALL I AM ASKING.

Well, you could do it with a pretty simple PHP script, if your host supports
PHP:

<?php

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

So if you set the action of your form to this script, it will e-mail you a
list of all the fields in your form and the values the user gave them. It
won't be especially pretty, but this should get you started.

Chris Finke
 
P

Peter Lozzi

Well, you could do it with a pretty simple PHP script, if your host
supports PHP:

<?php

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

So if you set the action of your form to this script, it will e-mail
you a list of all the fields in your form and the values the user gave
them. It won't be especially pretty, but this should get you started.

Chris Finke

Chris!

RIGHT ON BROTHER! Progress! Now...

HOW do I get that great script you shared with me ON THE SERVER and WORKING!?

I mean, do I creat like a text edit document with that script pasted in
it, and stick it in a folder?

WHERE DO I PASTE THAT GREAT SCRIPT?

Thank you, it looks like I am ON THE SCENT with your reply, if you BEAR
with me for a few more posts, I COULD ACTUALLY BE GETTING SOME OF MY
POTENTIAL CLIENTS' INFO!

Thank you! NOW WHERE DO I STICK THAT GREAT SCRIPT!?

Pete
 
M

Mark Parnell

Thank you! NOW WHERE DO I STICK THAT GREAT SCRIPT!?

You put it in a PHP file - that generally means a file with a .php
extension. Put the name of that file in the action="" attribute of your
form.

BTW: Your shift key is broken.
 
C

Christopher Finke

Peter Lozzi said:
HOW do I get that great script you shared with me ON THE SERVER and
WORKING!?

Copy the following (starting with the "<?php" and ending with the "?>") into
a text document and save it as form_processor.php

<?php

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

Now, copy this file (form_processor.php) to the same folder that your
contact.html file is in, on the server. (Make sure to change the
(e-mail address removed) address to your address.)

Then, change the line in contact.html that reads

<form action="" method="post" name="contact_form"
id="contact_form"mailto:[email protected]>

to
<form action="form_processor.php" method="post" name="contact_form"
id="contact_form">
Then, create a page called confirmation.html. Put this in the same folder
as contact.html on the server as well. This can include whatever
confirmation text you want, such as "Your comments have been received; you
will receive a reply in ## days."

After all this is done, try filling out the form and submitting it. If
everything worked, you should get an e-mail with your data and be shown the
confirmation page.

I hope this helps. Feel free to post any more questions you have.

Chris Finke
 
P

Peter Lozzi

Copy the following (starting with the "<?php" and ending with the "?>")
into a text document and save it as form_processor.php

<?php

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

Now, copy this file (form_processor.php) to the same folder that your
contact.html file is in, on the server. (Make sure to change the
(e-mail address removed) address to your address.)

Then, change the line in contact.html that reads

<form action="" method="post" name="contact_form"
id="contact_form"mailto:[email protected]>

to
<form action="form_processor.php" method="post" name="contact_form"
id="contact_form">
Then, create a page called confirmation.html. Put this in the same
folder as contact.html on the server as well. This can include
whatever confirmation text you want, such as "Your comments have been
received; you will receive a reply in ## days."

After all this is done, try filling out the form and submitting it. If
everything worked, you should get an e-mail with your data and be shown
the confirmation page.

I hope this helps. Feel free to post any more questions you have.

Chris Finke

Chris...

WOW! You have moved me closer than 4 books and 25 websites.

I am ALMOST there! I took your advice, and when I submit the form, it
actually opens the .php page with the script you created. I know this
isn't the desired result, and I am wondering what the heck I did wrong
now.

the form is still at:

http://www.vacavillemultimedia.com/contact.html

We're SO CLOSE! Thank you SO MUCH Chris for your help.

Pete
 
M

Mark Parnell

I am ALMOST there! I took your advice, and when I submit the form, it
actually opens the .php page with the script you created. I know this
isn't the desired result, and I am wondering what the heck I did wrong
now.

Doesn't look like your host supports PHP. You'll have to find out what
languages they do support, and use a script in one of those languages.
From your OP, they allow CGI (though whether they'll allow you to upload
your own may be a different matter); have a look at
http://sourceforge.net/projects/nms-cgi/

Doesn't your host have a form handler script already there anyway? I
know you said they didn't answer your emails - did you check their
support pages?
 
C

Christopher Finke

Peter Lozzi said:
I am ALMOST there! I took your advice, and when I submit the form, it
actually opens the .php page with the script you created. I know this
isn't the desired result, and I am wondering what the heck I did wrong
now.

Make sure you save the file as a text file, not as an HTML file. From what
I can tell, it looks like you saved it as HTML in a WYSIWYG editor. Paste
the text into Notepad, and save it as form_processor.php, making sure to
select "All files" from the "Save as type" option box (if you're using
Windows, that is).

Chris Finke
 
P

Peter Lozzi

Make sure you save the file as a text file, not as an HTML file. From
what I can tell, it looks like you saved it as HTML in a WYSIWYG
editor. Paste the text into Notepad, and save it as
form_processor.php, making sure to select "All files" from the "Save as
type" option box (if you're using Windows, that is).

Chris Finke

Chris...

Yeah, I created a new PHP document with dreamweaver. I made sure I
created a new dynamic PHP document, and not just an HTML or other
standard file.

The only thing I can think of now is that the host
(http://www.warped.com) does not support PHP by default, and that you
have to request to have it?

I mean, on the front page of their site it lists PHP as a feature.

I dunno. I think you have taken me as far as you can though... I
appreciate it more than you know. I will try in the coming days to
figure it out from here, unless there's something obvious I am doing
wrong that you can see...

Thanks!

Pete
 
P

Peter Lozzi

FYI, I opened a ticket with my server letting them know the PHP isn't
interpreting, and hopefully I will have it fixed soon. I'll keep you
all posted. Thank you so much for the education. You truly are what
makes usenet a joy.

Pete
 
J

Jeffrey Silverman

FYI, I opened a ticket with my server letting them know the PHP isn't
interpreting, and hopefully I will have it fixed soon. I'll keep you
all posted. Thank you so much for the education. You truly are what
makes usenet a joy.

A simple PHP script, just to see if PHP is working or not, is:

<? phpinfo(); ?>

Just that one line and nothing else in a file. Put said file on server.
Call it "phpinfo.php". Browse to URL.
 
P

Peter Lozzi

A simple PHP script, just to see if PHP is working or not, is:

<? phpinfo(); ?>

Just that one line and nothing else in a file. Put said file on
server. Call it "phpinfo.php". Browse to URL.

Thanks! When I execute that instruction, the browser opens the script
as a page, the script does not run. PHP must somehow be disabled,
although the server stats page says it is installed and running. It
will be iteresting to see what the help desk ticket response is.
Thanks for all your help, I'll keep you posted.

To see the results of the script, browse to:

http://www.vacavillemultimedia.com/info.php

Thanks again everyone...

Pete
 
N

Neal

Thanks! When I execute that instruction, the browser opens the script
as a page, the script does not run. PHP must somehow be disabled,
although the server stats page says it is installed and running.

Might want to contact your host about this.
 
J

Jeffrey Silverman

Might want to contact your host about this.

No. The problem is in the HTML/PHP source code, not in the server.

Look at the code!!

The code NEEDS ACTUAL GT AND LT SIGNS -- <? phpinfo(); ?>

WRONG:
&lt;? phpinfo(); ?&gt;

This is Dreamweaver's fault (OP mentioned using DW). You *must*
*NOT* use the WYSIWYG editor component of DW when editing PHP code!!

Try this (assuming you are on Windows):

1) Open Notepad (Start->Accessories->Notepad)
2) Cut-n-paste the PHP code

<? phpinfo(); ?>

3) Save file as phpinfo.php
4) upload file to server

Then test by browsing to the URL of the page! It should work at this point.
 
J

Jeffrey Silverman

Chris...

WOW! You have moved me closer than 4 books and 25 websites.

I am ALMOST there! I took your advice, and when I submit the form, it
actually opens the .php page with the script you created. I know this
isn't the desired result, and I am wondering what the heck I did wrong
now.

the form is still at:

http://www.vacavillemultimedia.com/contact.html

We're SO CLOSE! Thank you SO MUCH Chris for your help.

Pete

I just took a look at your form_processor.php script that you used as the
"action" for your email form. It suffers from the same problem -- DW is
sticking in HTML stuff that does not belong!

Repeat after me: I will not use Dreamweaver to editi PHP files. ... I will
not use Dreamweaver to editi PHP files. ... I will not use Dreamweaver to
editi PHP files.

Suggestions to solve this problem: Use a TEXT editor, NOT a WYSIWYG web
page editor (e.g. Dreamweaver)

http://www.google.com/search?q=php+text+editors&sourceid=mozilla&start=0&start=0&ie=utf-8&oe=utf-8
 
N

Neal

I will not use Dreamweaver to editi PHP files. ... I will
not use Dreamweaver to editi PHP files. ... I will not use Dreamweaver to
editi PHP files.

Is that Italian? ;)
 
P

Peter Lozzi

No. The problem is in the HTML/PHP source code, not in the server.

Look at the code!!

The code NEEDS ACTUAL GT AND LT SIGNS -- <? phpinfo(); ?>

WRONG:
&lt;? phpinfo(); ?&gt;

This is Dreamweaver's fault (OP mentioned using DW). You *must*
*NOT* use the WYSIWYG editor component of DW when editing PHP code!!

Try this (assuming you are on Windows):

1) Open Notepad (Start->Accessories->Notepad)
2) Cut-n-paste the PHP code

<? phpinfo(); ?>

3) Save file as phpinfo.php
4) upload file to server

Then test by browsing to the URL of the page! It should work at this point.

<Whew>

You've all bee right in different ways. The help desk ticket returned
that same info: DW html code was mucking up the page, script couldn't
run...

I fixed that, DW has a view that shows whether or not the code is being
accepted as PHP or HTML. That part is done, and PHP appears to be
functioning on the warped site just fine...

Now, when I try to process the form:
http://www.vacavillemultimedia.com/contact.html

Using the PHP that was kindly written by Mr. Finkle:
http://www.vacavillemultimedia.com/form_processor.html

I get this error message:

Warning: Cannot modify header information - headers already sent by
(output started at
/raid/ATL/vips/home0/pmlozzi/vacavillemultimedia.com/form_processor.php:7)
in
/raid/ATL/vips/home0/pmlozzi/vacavillemultimedia.com/form_processor.php
on line 15

This is the script I am using:

<html>
<head>
<title>form_processor</title>
</head>
<body>
<center>
<?

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

</body>
</html>


So the PHP is obviously being interpreted, but there is some error in
the script, I guess...

If there's anyone who can guide this novice just one step further, I
know it is you guys...

And I thank everyone again for my education with scripts, PHP, CGI and
the like. I am hoping I can use this knowledge to help out someone new.

Thanks again...

Pete
 
P

Peter Lozzi

Is that Italian? ;)

<Whew>

You've all bee right in different ways. The help desk ticket returned
that same info: DW html code was mucking up the page, script couldn't
run...

I fixed that, DW has a view that shows whether or not the code is being
accepted as PHP or HTML. That part is done, and PHP appears to be
functioning on the warped site just fine...

Now, when I try to process the form:
http://www.vacavillemultimedia.com/contact.html

Using the PHP that was kindly written by Mr. Finkle:
http://www.vacavillemultimedia.com/form_processor.html

I get this error message:

Warning: Cannot modify header information - headers already sent by
(output started at
/raid/ATL/vips/home0/pmlozzi/vacavillemultimedia.com/form_processor.php:7)
in
/raid/ATL/vips/home0/pmlozzi/vacavillemultimedia.com/form_processor.php
on line 15

This is the script I am using:

<html>
<head>
<title>form_processor</title>
</head>
<body>
<center>
<?

foreach ($_REQUEST as $key => $value){
$message .= $key .' = '. $value."\n";
}

mail("(e-mail address removed)","Email Form",$message);

header("Location: confirmation.html");
exit;

?>

</body>
</html>


So the PHP is obviously being interpreted, but there is some error in
the script, I guess...

If there's anyone who can guide this novice just one step further, I
know it is you guys...

And I thank everyone again for my education with scripts, PHP, CGI and
the like. I am hoping I can use this knowledge to help out someone new.

Thanks again...

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top