Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old February 5th, 2009, 07:19 AM   #1
New Member
 

Join Date: Feb 2009
Location: uk
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 chiltonwilliams is on a distinguished road
Why are forms so IMPOSSIBLE to understand!!!!!

Day 2. I have decided that my brain () will simply not allow me to learn how to setup a simple form in Dreamweaver using Streamline.net as my host. Its Impossible!.

Im sitting looking at a from I've created on Dreamweaver and now I just want it to work!!
Ive been given code by Streamline but they fail to mention where it goes in relation to dreamweaver. Stuff like,
eg, ini_set("sendmail_from", " user@yourdomain.com ");
mail($email_to, $email_subject, $email_message, $headers, '-fuser@yourdomain.com');
?>
So where does that go then??? and....
ini_set('sendmail_from', $email_from);
$email_to = "bob@bobsdomain.co.uk";
$name =$_POST['name'];
$email_from =$_POST['email'];
$email_subject = "Feedback from website";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";
I have decided that a link to my email address is the way forward unless anyone can point me to a tutorial (if there is one ive not read yet)

Why so hard!!??
chiltonwilliams is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 5th, 2009, 10:30 AM   #2
WebForumz Member
 

Join Date: Apr 2007
Location: UK
Age: 33
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Craigj1303 is on a distinguished road
Re: Why are forms so IMPOSSIBLE to understand!!!!!

Firstly you need to save all that data as a ".php" file all of it's own. That code they've given you doesn't actually sit in your HTML with your form.

The HTML form iteself needs to refer to the .php file. I have just setup a php form to work with Streamline. Although it took me ages to work it out it now works sucessfully!

This is the php info I saved to my server as "process.php":

Code:
<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$message = stripslashes($message);
mail('root@yourdomain.co.uk',$subject,$message,"From: $name <$email>", 
"-froot@yourdomain.co.uk");
header( "Location: http://www.yourdomain.co.uk/html/thanks.html" );
?>
The "-froot@yourdomain.co.uk"); is really important for the form to work with Streamline.net servers!!

and this is my HTML form that refers to this PHP. Both the HTML form and the relating process.php file are stored in the same directory on my server:

Code:
<form action="process.php" method="post">
<p>Name: input id="name" type="text" name="name" size="30" />  </p>
<p>Email: input id="email" type="text" name="email" size="30"  /> </p>
<p>Subject: <input id="subject" type="text" name="subject" size="30" /></p>
<p>Message: <textarea id="message" name="message"  cols="30" rows="10"></textarea></p>
<p><input type="submit" name="submit" value="Send" /></p>
</form>
Hope this helps
Craigj1303 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 5th, 2009, 12:30 PM   #3
New Member
 

Join Date: Feb 2009
Location: uk
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 chiltonwilliams is on a distinguished road
Re: Why are forms so IMPOSSIBLE to understand!!!!!

thats the sort of straightforward answer i was looking for thanks. Im glad its not just me having problems gettin this to work then. Will study your responce and see how i get on. I have been trying coffeecup forms today - supposed to be easy - didnt work. I still think this is far too complex for what it is. Up to now my understanding is to create a .php file, then create the form in Dreamweaver and in the 'action' box point it to my .php file, i think.
chiltonwilliams is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 5th, 2009, 07:58 PM   #4
WebForumz Member
 

Join Date: Apr 2007
Location: UK
Age: 33
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Craigj1303 is on a distinguished road
Re: Why are forms so IMPOSSIBLE to understand!!!!!

Quote:
Up to now my understanding is to create a .php file, then create the form in Dreamweaver and in the 'action' box point it to my .php file, i think.
That's exactly right!

If it's a basic contact form you are after you can cut and paste my .php info straight in to a new file in dreamweaver and save it as "process.php". All you would have to change is the "yourdomain.co.uk" bits to reflect your web address.

You could then cut and paste my form into your html and save that file. Then it should all be set up to work once you upload both files to the same directory on your server.
Craigj1303 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 6th, 2009, 08:15 AM   #5
New Member
 

Join Date: Feb 2009
Location: uk
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 chiltonwilliams is on a distinguished road
Re: Why are forms so IMPOSSIBLE to understand!!!!!

well ive tried that and guess what - didnt work. Im sure its impossible. Streamline has sent me a help file written in chinese which i have copied below.
First i created a simple comments box with this html;
<form id="form1" name="form1" method="post" action="sendmail.php">
<label for="textfield"></label>
<label for="textfield">comments</label>
<input type="text" name="textfield" id="textfield" />
</p>
<p>
<label for="Submit">submit</label>
<input type="submit" name="Submit" value="Submit" id="Submit" />
In Dreamweaver....
ACTION: set to sendmail.php
METHOD: Post
URL: sendmail.php
Relative to: Document

Then I have a php called sendmail, and i think this is where i go wrong. I have been given this example.......
ini_set("sendmail_from", " user@yourdomain.com ");
mail($email_to, $email_subject, $email_message, $headers, '-fuser@yourdomain.com');
?>

So i change it to this....
ini_set("sendmail_from", " peter@peterwilliams.org.uk ");
mail($email_to, $email_subject, $email_message, $headers, '-fpeter@peterwilliams.org.uk');
?>


I refuse to believe its this difficult to add a comments form to a website!!
Here is the responce i have from stremeline net
Thanks for any help.

To prevent spam being sent through our webservers, there are certain conditions that must be met before our SMTP servers will send the email.
1) Email must be sent to, or from, an email address hosted by Streamline.net. An email address hosted by Streamline.net is not the same as a domain name hosted by Streamline.net. If your domain's MX record points to another email provider, it will not count as being hosted by Streamline.net.

2) To stop misuse of your form by third parties the sendmail_from variable should be set to your Streamline.net hosted email address. While access to the php.ini file is restricted on our shared environment, you can set this variable using the ini_set() command, shown below.

3) A fifth parameter -f should be added to the sendmail function. This will set the name of the from email address.

In its basic form, a simple sendmail script will look like this:

ini_set("sendmail_from", " user@yourdomain.com ");
mail($email_to, $email_subject, $email_message, $headers, '-fuser@yourdomain.com');
?>

Provided that you set the sendmail variable, before attempting to send the email. Specify the from address as a fifth parameter in the sendmail function, and the email is either to, or from, a Streamline.net hosted email address you should have no problems.


Example
This example will take the information from a feedback form, send it to you in an email message, then forward the customer to a "thank you for your comments" page. In this example we will use bobsdomain.co.uk as the domain name. There is a mailbox hosted with Streamline.net called bob@bobsdomain.co.uk.
A simple feedback form

First of all we need to create a feedback form that will receive the data. We will call this form feedback.html. In its most basic form, it can look like this:


Email address:

Name:

Message:

Not the prettiest form, but it can be tidied up, and validation can be added at a later date. This form has three fields (email address, name and message) that users can fill in. Once the user click the Submit button, it will collect the information contained within the fields, tag the information as "email, name and message", then send the information to sendmail.php.

The sendmail script

Now we have a form that sends information to a script, we need to create a script to send the email. In this example, we will name the script sendmail.php as this is the address the our form is submitting the data to. In order to send an email, we need certain information (variables), so lets set them first.

ini_set('sendmail_from', $email_from);
$email_to = "bob@bobsdomain.co.uk";
$name =$_POST['name'];
$email_from =$_POST['email'];
$email_subject = "Feedback from website";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";

Now lets build the message of the email with the users name and comments.

$message= "Name: ". $name . "\nComments: " . $comments;

Finally, let's send the email. If the email is sent we will go to a thank you page, if there is an error we will display a brief message.

$sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from');
if ($sent)
{
header( "Location: http://www.bobsdomain.co.uk/thankyou.html" );
} else {
echo 'There has been an error sending your comments. Please try later.';
}
?>


This script does not have any validation or error checking, so it is not recommended that you copy it directly to your website, however, it does show the basics of sending email from our webservers, and can be used as a framework for your own scripts.
chiltonwilliams is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 6th, 2009, 01:01 PM   #6
New Member
 

Join Date: Feb 2009
Location: uk
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 chiltonwilliams is on a distinguished road
Re: Why are forms so IMPOSSIBLE to understand!!!!!

I seem to have come up with a soloution. Get coffeecup form builder and it works! but not through my isp, but to my gmail account. All i need to do now is look at the code and work out what to change for it to work with my isp.
chiltonwilliams is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
please help me understand! CSS Menu in IE GONE WRONG! daraclare HTML, XHTML and CSS 12 April 29th, 2008 03:15 PM
Idk y? but i just dont understand positioning camcool21 HTML, XHTML and CSS 8 December 17th, 2006 07:33 AM
Mission Impossible?? garry2006 JavaScript 4 November 22nd, 2006 06:58 PM
Is this impossible? bob_visualefx Web Hosting and Domains 3 May 26th, 2006 03:57 PM
Asking for the impossible... Phoenix HTML, XHTML and CSS 1 February 12th, 2006 11:34 AM


Search Engine Optimization by vBSEO 3.2.0 RC8