LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-13-2005, 06:38 AM   #1
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Rep: Reputation: 30
PhP Problems (email form)


I have been trying to find a general PhP email form that would let me modify it when I needed to.
I gave up the look and decided the only way to get what I want is to do it myself. Problem is that I know html well, but PhP is new to me.

I tried to create a simple PhP form. But I am getting errors when I try and use it at the website.

These are the latest errors:


Warning: mail() expects at most 5 parameters, 12 given in /mnt/web_m/d04/s40/b025e49f/www/sendmail.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at /mnt/web_m/d04/s40/b025e49f/www/sendmail.php:14) in /mnt/web_m/d04/s40/b025e49f/www/sendmail.php on line 16


I know this is going to be really easy to solve and I will kick myself later.

First I will post the contact.html and then the sendmail.php


contact.html (I left the html tags out and the first < and last >)



form method="post" action="sendmail.php">
Name: <input name="name" type="text" /><br />
Phone: <input name="number" type="text" /><br />
Email: <input name="email" type="text" /><br />
Best time to contact you:<br />
<textarea name="contact" rows="10" cols="40">
</textarea><br />
This is in regards to:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form


Now here is the sendmail.php (I left out <? and ?>)


$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$name = $_REQUEST['name'] ;
$number = $_REQUEST['nuumber'] ;
$email = $_REQUEST['email'] ;
$contact = $_REQUEST['message'] ;

mail( "myemailgoes@here.com", "Attention *Test Form*",
$name, "From: $email",
$number, "From $email",
$email, "From $email",
$contact, "From $email",
$message, "From: $email" );

header( "Location: ty.html" );


Can someone please tell me what I am doing wrong. I think I really messed this up.Thank You.

Webwolf
 
Old 10-13-2005, 08:17 AM   #2
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 602

Rep: Reputation: 49
http://www.php.net/manual/en/function.mail.php
 
Old 10-13-2005, 09:23 AM   #3
jilljack
LQ Newbie
 
Registered: Oct 2005
Posts: 16

Rep: Reputation: 0
Also, PHP code should start at the begining of the page with 'ob_start();'
 
Old 10-13-2005, 09:49 AM   #4
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Original Poster
Rep: Reputation: 30
Thank you both


Webwolf
 
Old 10-13-2005, 12:21 PM   #5
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Original Poster
Rep: Reputation: 30
Ok. I got it figured out. I am able to send it to a few different emails. Now here is a problem. I am researching it now but if anyone can give me a heads up and save me some time I would appreciate it.

When the mail is sent to a frontier email the recipient does not recieve it. My guess is that the message sent has "from: anonymous(at)cgi3.cgi3" and frontier see this as spam and filters it out so it doesn't reach the intended person. My question is this. Is there a way I can just add something to my (sendmail.php or contact.html) so my own email address shows up instead of anonymous(at)cgi3.cgi3?


Thanks
Webwolf

Last edited by webwolf70; 10-13-2005 at 12:23 PM.
 
Old 10-14-2005, 05:13 AM   #6
webwolf70
Member
 
Registered: Feb 2004
Distribution: Windows XP. I gave up with Linux & I left LQ.
Posts: 502

Original Poster
Rep: Reputation: 30
Finally. I got the exact type of php email form I wanted. And I can customize it as needed. Perfect. And man did I really mess up the one I did first(posted in first message,) lol.
Here is what it looks like now. I am posting this in case someone else may need a guide/template or ideas on how to do this simply.



<?php
if(isset($_POST['submit'])) {

$to = "sendingtoemail";
$subject = "Test Form";
$name = $_POST['name'];
$number = $_POST['number'];
$mail - $_POST['mail'];
$contact - $_POST['contact'];
$message = $_POST['message'];
$from = "fromemail";
$headers = "From: " . $from;
$params = "-f" . $from;

$body = "From: $name\n Number: $number\n E-Mail: $mail\n Contact: $contact\n Message:\n $message";

echo "Data has been submitted to $to!";
mail($to, $subject, $body, $headers, $params);
} else {

echo "No Data has been sent!";

}
?>


It took me awhile but using linux has taught me not to just settle but to get things done and set up the way I want them.

Webwolf

Last edited by webwolf70; 10-14-2005 at 07:33 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Massive email Problems with Postfix and PHP alcros Linux - Software 2 10-23-2005 08:25 AM
PHP form help Zeppelin_Fan Programming 5 03-24-2005 04:47 PM
Sending a form to an email address problems! cucolin@ Programming 1 06-23-2004 05:21 AM
Form info to the db and then to my email Kuri Programming 0 04-25-2004 11:12 AM
Problems with php 4.2.1 form-data and hidden variables coea77 Programming 1 10-10-2002 03:24 AM


All times are GMT -5. The time now is 11:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration