Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
New to PHP
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Re: New to PHP
New to PHP
16-12-2010 4:18 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Hi all,
Looking at creating an online form so people can send me info via my website. I am trying to code a very simple page but have and error when trying to call it.
I am using dreamweaver that the form properties points to the PHP file which has the 755 permissions on the PHP file but when the PHP file is called I get a 405 Method Not Allowed, CGI was switched opn a while back, I suspect there is something wrong with my code so I have attached it below.
<?php
$emailSubject = 'New Membership Details';
$webMaster ='webmaster@test123.com;
$emailField = $_POST['email'];
$body = <<EOD
Email Address: $email
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: test/html\r\n";
$sucess = mail($webMaster, $emailSubject, $body, $headers);
echo "sucess";
?>
The example was from this webpage http://www.tutvid.com/tutorials/dreamweaver/tutorials/phpFormHandler.php I get the jist but there is something I am not doing right.
Please Help.
Looking at creating an online form so people can send me info via my website. I am trying to code a very simple page but have and error when trying to call it.
I am using dreamweaver that the form properties points to the PHP file which has the 755 permissions on the PHP file but when the PHP file is called I get a 405 Method Not Allowed, CGI was switched opn a while back, I suspect there is something wrong with my code so I have attached it below.
<?php
$emailSubject = 'New Membership Details';
$webMaster ='webmaster@test123.com;
$emailField = $_POST['email'];
$body = <<EOD
Email Address: $email
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: test/html\r\n";
$sucess = mail($webMaster, $emailSubject, $body, $headers);
echo "sucess";
?>
The example was from this webpage http://www.tutvid.com/tutorials/dreamweaver/tutorials/phpFormHandler.php I get the jist but there is something I am not doing right.
Please Help.
Message 1 of 2
(948 Views)
1 REPLY 1
Re: New to PHP
17-12-2010 1:04 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
There are a number of typos in your code, but it's easier to show you a version that works.
Note: relying on $email being set from the name of the form field will work at the moment because register_globals is on. However it will stop working when that is turned off. So best not to rely on it; set values you need from the $_POST global as done above in your original code. I made use of the extracted variable later.
David
Edit: I should have mentioned I set permissions on that file to 700. The directory I put it in has permissions 710.
<?php
$emailSubject = 'New Membership Details';
$webMaster ='webmaster@my.email.address';
// $emailField = $_POST['email']; // commented out and replaced by next line ...
$emailField = 'me@my.email.address'; // ... for convenience in this test
$body = <<<EOD
Email Address: $emailField<br>
Subject: $emailSubject<br>
EOD;
$headers = "From: $emailField\n";
$headers .= "Content-type: text/html\n"; // you had 'test/html' here
$success = mail($webMaster, $emailSubject, $body, $headers);
echo $body,$success;
?>
Note: relying on $email being set from the name of the form field will work at the moment because register_globals is on. However it will stop working when that is turned off. So best not to rely on it; set values you need from the $_POST global as done above in your original code. I made use of the extracted variable later.
David
Edit: I should have mentioned I set permissions on that file to 700. The directory I put it in has permissions 710.
David
Message 2 of 2
(358 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page