View Full Version : How does this email form work w/o a post reference?

07-15-2007, 06:17 PM

I recently stumbled across a webpage that has the following code for their contact form on their webpage, contact.php:

<form id="emailform" method="post" action="/contact.php">
<fieldset id="contact_form">
<legend>Please fill out the form completely.<br />You will be added to my mailing list unless you indicate otherwise.</legend>
<input type="hidden" name="sendnow" id="sendnow" />
<label for="fromname">Name</label>
<div><input name="fromname" type="text" id="fromname" size="40" value="" /></div><br />
<label for="from">Email Address</label>
<div><input name="from" type="text" id="from" size="40" value="" /></div><br />
<label for="what">Subject</label>
<div><input name="what" type="text" id="what" size="40" value="" /></div><br />

<label for="message">Message</label>
<div><textarea name="message" cols="50" rows="10" id="message"></textarea></div>
<a href="#" onclick="document.forms[0].sendnow.value='sent';document.forms[0].submit();return false;" id="contact_submit">Send</a>

There is no javascript reference or php reference in any other portion of the code to where this contact form points to translate the post information. Any ideas on how the heck this thing works and/or how I can find a form like it?

I figured the following line might be a clue:

<a href="#" onclick="document.forms[0].sendnow.value='sent';document.forms[0].submit();return false;" id="contact_submit">Send</a>

Unfortunately, I don't see any reference to this string or anything similar to it when I search around on Google, etc.

Hopefully one of you pro's can help?

Thanks a bunch in advance for reading my post!


07-15-2007, 06:40 PM
I am not sure what you are talking about, because the form submits back to the same url -

<form id="emailform" method="post" action="/contact.php">The only code you see in the browser is the HTML/CSS/Javascript content that is output to the browser from the web server. Any PHP form processing code that might exist on that page only exists and is executed on the server.

07-15-2007, 06:46 PM
Thanks for the reply, exactly. Since it submits back to the same url I can't find the code that translates the form. Is there any way to find the location of the script that is getting run here?

It seems like there has to be some sort of reference to it so that the "send" or "submit" button will know where to send the form information to execute the code to translate it and email it, etc.

07-15-2007, 06:56 PM
The action="..." parameter in the <form....> tag is where the form submits the data to.

07-15-2007, 06:59 PM
Heya, thanks for getting back to me again....

The action tag is pointing to the same page I'm getting the form code off of, though, and there isn't any reference to any php script or javascript on that same page to translate the code.

I was hoping I could find the area that contains the email address info, etc etc, so I can modify it and use it on my own home page.

Does this make sense? Is the form script just invisible or something?

Thanks again,

07-15-2007, 07:14 PM
PHP code and variables only exist on the web server. Browsing to a .php file causes the PHP code to be parsed and executed on the web server. You only get any output from PHP echo/print/print_r... statements or any static in-line HTML in that file that is outside of any php code.

The only way to see php code in a .php file is through direct access to that file on the server, using FTP or a hosting account control panel... (or if someone places an additional copy of that code on the server using a file extension that is not parsed by the PHP language engine.)

If your question is really "what does form to mail PHP code look like?" search the Internet for "PHP form to email" scripts and/or look here - http://www.hotscripts.com/PHP/Scripts_and_Programs/Form_Processors/index.html

07-15-2007, 07:16 PM
I will research what you just showed me, thanks a bunch for taking the time out to help.

Have a great day,