# Do I need a new program?



## motdaugrnds (Jul 3, 2002)

I'm creating a store to sell about 30 items via html. I'm using "Note Tab Light" to create the html files. I've got it just about completed and need a "contact me" form that has some protections built into it. 

In searching the net for such coding I find many have a "php" file extension necessary. Thus, my question: Do I need a new program in order to create a php file?


----------



## mistletoad (Apr 17, 2003)

No. You can write php just the same way - in fact you can rename your file.html to file.php and it instantly becomes a php file


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> I'm creating a store to sell about 30 items via html. I'm using "Note Tab Light" to create the html files. I've got it just about completed and need a "contact me" form that has some protections built into it.
> 
> In searching the net for such coding I find many have a "php" file extension necessary. Thus, my question: Do I need a new program in order to create a php file?


Php files are normally for php code, while html files are for html code. I keep it that way in my work.

You can create php code with any text editor but it's better to use a php editor. Php editors color code different parts of code statements to help you error check the code as you create it. Many php editors are free. Kantheros is a good php editor for Windows. That's what I use to edit and troubleshoot php code.

http://sourceforge.net/projects/kantharos/

But there are tons more. There are free php editors for all operating systems.

http://en.wikipedia.org/wiki/List_of_PHP_editors


----------



## motdaugrnds (Jul 3, 2002)

Nevada, after getting that php editor and then creating that php file, will my html files accept it?


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> Nevada, after getting that php editor and then creating that php file, will my html files accept it?


You normally keep the php code in a php file. The objective of php is so you can generate html from conditional arguments, as opposed to a flat html page.

Perhaps I don't understand the question.


----------



## motdaugrnds (Jul 3, 2002)

It is my stupidity about such matters that is probably causing you not to understand my question.

I am attempting to set up a "contact form" that has some safety built into it; and the only information I'm finding as to how to do this tells me I need a HTML page as well as a PHP page. I actually have no idea what this means; however, I'm thinking these pages need each other to create that contact form I want to use in my store.

I can easily create the HTML form because I use the Note Tab Light editor and it has the option of saving whatever I create in with the .html extension. However, I have no way of creating the page/file with the .php extension. Thus, my inquiry into getting a php editor of sorts. Now my question pertains to how this .php file fits in with the rest of my work. I've created my entire store using html coding. 

Having a .php file is throwing me as I don't understand if it will be accepted by my html coding...and maybe this is a foolish question in that the first part of that "contact me" form IS a html page. So maybe when I create the php file to complete the contact form, if I just place it inside the same folder as the html file it will be working with, that will be all that is required. 

Clearer?


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> I am attempting to set up a "contact form"


That's a very common thing to setup. What I suggest you do is to look for a free php script that does that for you. There's no reason for you to reinvent the wheel when there are plenty of free form-to-email scripts available. Take a look at these scripts. I'm sure you'll find something you like.

http://gscripts.net/free-php-scripts/FormMail_Scripts.html

I think what they're suggesting is that you insert an in-line frame in an html page, then set the php page in the frame. If you do that the html page will fetch the php and set it in the frame and your general web page appearance will remain constant.

If you are a beginner you might just link to the php form and leave it at that. If you want to try to insert an in-line frame in an html page, I suggest you do it with a free graphical html editor, like Kompozer. I think Kompozer does in-line frames.


----------



## motdaugrnds (Jul 3, 2002)

I did insert the html coding into my index file and placed the php file in that folder. A contact form did show up on my test site when pulled up yet the "button" was not hyperlinked and it had a couple of words next to it that were. When I clicked on the hyperlink, my entire outlook express email program showed up. I sure don't want others to see that!


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> I did insert the html coding into my index file and placed the php file in that folder. A contact form did show up on my test site when pulled up yet the "button" was not hyperlinked and it had a couple of words next to it that were. When I clicked on the hyperlink, my entire outlook express email program showed up. I sure don't want others to see that!


Do you have a link I can follow to that page?

To give you an idea if what I was suggesting, here is an example of a script imbeded in an html page with an inline frame.

http://desertbreezenv.com/guest.html

That guestbook application is actually a PERL script, but a php script should work pretty much the same.


----------



## motdaugrnds (Jul 3, 2002)

I don't remember where I got it; but I will place the html part here and the php file on a separate post. (The html part I placed into my html coding of the index file. The php file I placed inside the "folder".)

<! Below is suppose to be the "contactme form" (2-part with html and php files). !>
<form name="contactform" method="post" action="send_form_email.php">
<table width="450px">
<tr> 
<td valign="top"> 
<label for="first_name">First Name *</label> 
</td> 
<td valign="top"> 
<input type="text" name="first_name" maxlength="50" size="30"> 
</td> 
</tr> 
<tr> 
<td valign="top""> 
<label for="last_name">Last Name *</label> 
</td> 
<td valign="top"> 
<input type="text" name="last_name" maxlength="50" size="30"> 
</td> 
</tr> 
<tr> 
<td valign="top"> 
<label for="email">Email Address *</label> 
</td> 
<td valign="top"> 
<input type="text" name="email" maxlength="80" size="30"> 
</td> 
</tr> 
<tr> 
<td valign="top"> <label for="telephone">Telephone Number</label> 
</td> 
<td valign="top"> 
<input type="text" name="telephone" maxlength="30" size="30"> 
</td> 
</tr> 
<tr> 
<td valign="top"> 
<label for="comments">Comments *</label> 
</td> 
<td valign="top"> 
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> 
</td> 
</tr> 
<tr> 
<td colspan="2" style="text-align:center"> 
<input type="submit" value="Submit"> <a href="http://www.freecontactform.com/email_form.php"></a> 
</td> 
</tr> 
</table> 
</form> 
<! This ends the contact me form hyperlink. It did show up with a button, but the button brought up a white page with my personal email address on it and a line of coding. !>


----------



## Nevada (Sep 9, 2004)

That code resolves into a pretty good looking form.


----------



## motdaugrnds (Jul 3, 2002)

Here is the php file.

Could not access it anymore and that Kantharos program is acting funny; so I am trying to delete it and it won't let me. grrrr


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> Here is the php file.
> 
> Could not access it anymore and that Kantharos program is acting funny; so I am trying to delete it and it won't let me. grrrr


Do you have some reason to object to using a graphical html editor? You really don't need a php editor for this project. This is just a simple copy & paste job. Now that I've looked at the app, there's no need for an inline frame. Just upload the package, run the installer, and paste the result.


----------



## motdaugrnds (Jul 3, 2002)

Oh dear Nevada I have read your instructions over several times and I still don't understand what you've said. I know it is my fault so do not start blaming yourself. Sometimes words just don't make sense to me.

I do understand what you said when you asked if I object to using a graphical html editor. The html editor I use is Note Tab Light and I could not find a php save option on it.

When you say it is just a simple copy/paste job; so all I need do is upload the package, run the installer and paste the result, I am totally confused. What is an "inline frame"? Upload what package? Since you said I don't need a php editor, what am I suppose to install and paste what result....as you can see, Nevada, my mind will not wrap around what you've said in any type of way that makes sense to me.

I know you've been trying to help me and I thank you for that. I am just hard to work with at times and this appears to be one of those times.


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> Oh dear Nevada I have read your instructions over several times and I still don't understand what you've said. I know it is my fault so do not start blaming yourself. Sometimes words just don't make sense to me.
> 
> I do understand what you said when you asked if I object to using a graphical html editor. The html editor I use is Note Tab Light and I could not find a php save option on it.
> 
> ...


Let me save us both a lot of time. PM me with the html file you want the code pasted into and the email address you want the form to go to. I'll paste it for you.


----------



## SeanInVa (Oct 3, 2013)

I just want to toss this out there as motdaugrnds might find it helpful - 

.html and .php files are nothing more than straight text files. Your graphical editor may not support PHP code, and this may not let you save files with the extension .php

So you can edit PHP code in Notepad, or any other basic text editor and save it out as any other file.

Also, PHP is what is know as "Server Side Code" or "Server Side Scripting". It's a programming language and interpreter that takes in PHP code files and spits out HTML (in most cases, but it can "spit out" anything you tell it to).

So, what you are trying to do is embed this contact form within your website which is mostly HTML. HTML is "client side code". It is processed by your web browser and then displayed as graphical elements therein (text, paragraphs, tables, images, etc).

An "inline frame" is an "iframe", created using the HTML iframe tag.

Typically, a contact form that is processed by PHP or some other server side code starts out as a basic HTML form with input boxes and/or dropdowns and other input elements. The "action" property of the form tag tells the browser where to send the input data. You could specify a .php page here, and inside that php page, you would write code to process the input data. Then, after verifying the data is safe and proper, you can *programmatically* send an email using this data.

As a basic example, consider this very simple HTML page with a small contact form:


```
<html>
	<head><title>Example Contact Form</title></head>
	<body>
		<form method="get" action="contactform.php">
			Your name: <input type="text" name="txtName" /> <br>
			Your email: <input type="text" name="txtEmail" /> <br>
			<input type="submit" value="Submit" />
		</form>
	</body>
</html>
```
I use method="get" here so you can see how the data is passed along. This method will pass it in the query string (the address bar of the browser, basically).

Now, you could have that php page, contactform.php look something like this:

```
<?php
	// use the built-in PHP email functions 
	// to send the contact data sent over to a pre-determined email address

	$emailTo = '[email protected]'; // this is not a real email address! Change it if you try to use this as a base for anything you actually put on your website
	$formContactName = $_REQUEST["txtName"];
	$formContactEmail = $_REQUEST["txtEmail"];

	$emailText = "This data was submitted by the contact form - \r\n"; // \r\n are escape sequences to insert a carriage return and line feed into the email text (for formatting)
	$emailText += "Contact Name: " . $formContactName . "\r\n"; // the "." is a concatenation character in PHP in this instance. So we concatenate the value held in $formContactName to the rest of the string/text
	$emailText += "Email Address: " . $formContactEmail;

	// use PHP's mail function to send the email
	// its syntax is mail(to, subject, message)
	// this function returns False if it fails, and True if it succeeds
	if (mail($emailTo, "Contact Form Submission", $emailText) == True) {
		echo "The email was successfully sent!";
	} else {
		echo "There was a problem sending the email!";
	}
?>
```
When things are working properly, you will want to change the form's method from "get" to "post", so the user doesn't "see" the submitted values in their address bar.

This all assumes you are hosting you website on a host that supports PHP 

Hope that helps!


----------



## Nevada (Sep 9, 2004)

SeanInVa said:


> An "inline frame" is an "iframe", created using the HTML iframe tag.


It turns out that he doesn't even need to use an iframe. I just pasted the code in his html page. He hasn't gotten back to me.


----------



## motdaugrnds (Jul 3, 2002)

WOW I'm trying so hard to understand what both of you have told me. It all sounds so simple until I start doing it. 

I've copied the html and the php both of you have offered me into my Note Tab Light editor. Turns out I can save the php file with that php extension, which I had not known I could do.

Sean, your coding is real simple and seems I can place the html portion into my index file as I have wanted to do (saving the php portion as a separate page in the same folder). Yet it does not profide a place for comments/questions, which I really want. Nor does it contain any email protections against autoers.

Nevada, what you sent me via PM was like a brand new site when all I want is a simple contactme form situated in a corner of the one page I have. 

I am so grateful for your help. Seems you two and another who is also very kind to help are indeed getting me to think in ways I haven't before. (I'm just not a technically minded person; however, I do believe I am starting to understand.)

Thank you both so much.


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> Nevada, what you sent me via PM was like a brand new site when all I want is a simple contactme form situated in a corner of the one page I have.


OK, first thing you need to do is upload ALL of the files that were contained in the zip file to your web space.


----------



## SeanInVa (Oct 3, 2013)

Well, I was just providing a sample. You will need to edit the HTML of the contact page to add new fields. You probably want to add a "textarea" to hold comments. You may want a phone number field. I will leave that exercise up to you to learn, but if you hit a snag, let us know and we will help 

For the PHP side - again, that was an example that is about as basic as it can get. You will need to add code to handle any new input fields you add on the HTML side.

You are also going to want to add code to do input checking as you see fit and maybe put in place checks to ensure the page submitting the form data is coming from your domain (so that I don't create a little "bot" program to send thousands of requests to that PHP page to spam you) - this information is passed in the HTTP Referrer bit of the HTTP header. You may also want to limit the number of submissions over a set time period.

As Nevada mentioned, simply finding an existing contact form script would do most of this already - BUT you don't LEARN anything that way.

Being that you are trying to develop a web store, and you seem to be at the very beginning stages of learning all this (which is 100% fine btw, we all have to start somewhere!) you may just want to install a full-blown PHP based shopping cart system. OSCommerce, Magento, etc. I say this because you are going to have a few things to consider for a web store:

1. are you accepting credit cards? paypal? or are you manually processing everything?
1a. if accepting any kind of online payment, even paypal, you are going to have some significant PHP coding to do to integrate those items with your website.

2. If you are collecting personal information on your website, I highly recommend you purchase and install a SSL certificate, and force/redirect traffic to the https protocol.

3. Will you be using a database? Where are you storing orders? products for sale and prices? inventory levels?

4. You will want to read up on web app security, namely XSS and SQL injection vulnerabilities (SQL only if using a database of some fashion)

Learn to run your website pages through HTML validators (if your web editor doesn't have them built in). This will check your HTML code and tell you where you have invalid markup. One such validator is here: http://validator.w3.org/

It's awesome that you are trying to learn all this, but be aware that you may have a long road ahead of you as far learning goes


----------



## motdaugrnds (Jul 3, 2002)

Thank you both for the information.

I'm really not that interested in creating a large store. Nor am I interested in learning a lot of coding. All I want to do is set up a one-page store with a contact button for questions to sell about 30 items. After that is done, I doubt I ever use the store for much of anything except a few concoctions I use for health purposes around here, i.e. salve, tea, extracts, etc. And I may not even do that as I don't have a lot of time.

I like the store I've set up thus far, though I still need to get some items up and the paypal buttons on. Then with the contactme button/form all will be done. You can check out what I've accomplished thus far and that is just about all I'm going to do to this. I sure don't need a shopping cart or anything like that. I'm just keeping my store very simple.

Check it out at http://motdaugrnds.com/farmsales It sure isn't complete and a lot of my pictures are not up yet because it is taking time I don't have much of to sort out all this jewelry. But they should be up within a week or so.


----------



## Nevada (Sep 9, 2004)

motdaugrnds said:


> Check it out at http://motdaugrnds.com/farmsales


Now that I've looked at your website I see the it's really a single page site. I'm wondering if you are wanting to place the contact form in the right margin where it currently says "Contact Me."


----------



## motdaugrnds (Jul 3, 2002)

Yes Nevada. A simple form that would have some built-in protections and not carry the viewer off to some other page is what I have been attempting to set up in that lower right-hand column. It sounded so simple yet has turned into a nightmare.


----------

