Need a new web host or having a problem with a script? Tips and advice on the best way to design, build and maintain your most valuable asset - your website!

Problems with getting forms to work

PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:

Problems with getting forms to work

Hi all, I'm having problems getting forms to work.

I'm using the latest version of dreamweaver and have the Affilorama web hosting.

I have a simple "contact us" form made up with minimal search options on it, but I'm not sure how to get the form data captured and stored onto a database :?

Any help would be appreciated.

Colin
  • 0
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
You can use a simple php script that will send their answers directly to an email address you want. You do not need a database or anything. I will give more details later. I'm at school now.

Adrian,
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
Thanks Adrian,

I look forward to your update.
  • 0
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
I am guessing that you have some knowledge of HTML? This is going to require that you work in the "CODE" view of dreamweaver but it really isn't hard. Just takes a little to understand.

You will have 2 pages in this process. Your HTML page with the form on it, and a PHP page which is not seen by the visitors. The answers from your HTML are forwarded to the PHP then sent to your email.

So let us say your contact page on your website is contact.html

For simplicity sake, I am only going to have one thing on the form. A place for visitors to write their name.

An example of the code of this form is like so...
----------------------------------------------------------------------

<form action="contact.php" method="post">

<input type="text" name="name">

<input type="submit" value="Submit" />

<input type="reset" value="Start Over" />
</form>

----------------------------------------------------------------------
What is this telling us? The action of the form will send your answers to a script on a page called contact.php. Do not worry about method="post". That just means to send the information.

Input type specifies what kind of thing is in the form, a radio button, a checkbox etc.... input type="text" means a line you can write in.

Input type="submit" is the submit button to send the form.
Input type="reset" clears the form to start over.

The value is what is written on the buttons.

Now you will notice that the information we need to send has been given a name....

<input type="text" name="name">

We have to name each part of the form something, so when we send information we can distinguish what we are sending. As you can see, this field has been labeled "name".

------------------------------------------------------

Now for our actual script page.

You can just copy and paste this.

----------------------------------------------------


---------------------------------------------------
If you need to add more elements simply place for <input type="text" name="giveitanamehere" /> Also, be sure to change the URL of the thank you page and put your email in there!

Then in the script page just place those values into what is sent to you... so if you added a field for the visitors age you would add this to the code....



This will be confusing at first. Let me know how it goes.

Adrian,
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
ok, thant's great.

I'll get to work on it now and let you know how I get on.

Thanks for your time and effert.
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
Hi again Adrian, this is my first time with html, so I'm a bit perplexed.

I managed to get the results page sent to my email, but it only sends the label of the field without the contents.

Here's the code after I inserted my details;


The email this generates is:

Name: , Email_Address: , Comment:

Hope you can see something here

Colin
  • 0
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
Can I see your HTML part? Just for the form.
  • 0
PremiumMember
4ubest
Posts: 16
Joined: 23 Aug 06
Trust:
Adrian,

Can that php form be modified to pick up the IP address
and Date/Time ?

Thank you,

Peakperformance Ken

Example of Powerful RSS Technology and Product
http://quikonnex.com/channel/page/barnone-lifewave
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
<form action="Results.php" name="Contact Form" target="_self" class="smallText" id="Contact Form" onsubmit="MM_validateForm('Name','','R','Comment','','R');return document.MM_returnValue">
<div align="left">
<p>Name (R) <br />
<input name="Name" type="text" id="Name" onblur="MM_validateForm('Name','','R','Email_Address','','NisEmail','Comment','','R');return document.MM_returnValue" size="24" />
<br />
<br />
E-mail Address<br />
<input name="Email_Address" type="text" id="Email_Address" size="32" />
<br />
<br />
Comment (R) <br />
<textarea name="Comment" cols="40" rows="6" id="Comment"></textarea>
<br />
<br />
<br />
<input type="reset" name="Reset" value="Reset" id="Submit" />
<input name="Submit" type="submit" id="label" onclick="MM_validateForm('First_Name','','R','Email_Address','','NisEmail','Comment','','R');return document.MM_returnValue" value="Submit" />
</p>
</div>
</form>
  • 0
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
Try using this.. I see javascript in here... is it absolutely essential you need to verify the form?

Try this anways just to test.

<form action="results.php" method="post"">
<div align="left">
<p>Name (R) <br />
<input name="name" type="text" />
<br />
<br />
E-mail Address<br />
<input name="email" type="text" />
<br />
<br />
Comment (R) <br />
<textarea name="comment"></textarea>
<br />
<br />
<br />
<input type="reset" value="Reset" />
<input type="submit" value="Submit" />
</p>
</div>
</form>

There is stuff in there that is not needed. Try to keep your pages named with lower case letters and try to use single words to name the fields. ID's are not needed for this.

Ken - I am not sure on the date/time stamp... do a google search for php form date time stamp and you will get a lot.

Adrian,
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
I'll try it out in the morning.

Thanks!
  • 0
PremiumMember
cdidcott
Posts: 79
Joined: 23 Aug 06
Trust:
Adrian

That code came up with the same result as before.

Out of desperation I tried a few alterations just to see if I could get lucky.

I did! Super lucky, with a little educated guessing.

Here's the code that worked.


Thanks for all the help.

You're my IDOL now :D

Colin
  • 0
Last edited by ampie g on 25 Jan 10 1:31 am, edited 1 time in total.
Reason: displayed as code to remove broken link