Form help PLEASE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rjmxracer1
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 9:09 am

Form help PLEASE

Post by rjmxracer1 »

alright i have this form on my website and the form is made with HTML and i want to have it submit and be sent through e-mail.
This is the code but nothing is working what so ever:

Code: Select all

<?php
if ($_POST['SUBMIT'] == 'Send the Data')
{
$content = "Name: " . $_POST['personal_name'] . "\n"; 
$content .= "Company Name: " . $_POST['company_name'] . "\n";
$content .= "Phone #: " . $_POST['contact_phone'] . "\n";
$content .= "Contact time " . $_POST['contact_time'] . "\n"; 
$content .= "E-mail: " . $_POST['contact_e-mail'] . "\n";
$content .= "Current Web: " . $_POST['current_web'] . "\n";
$content .= "Web URL already: " . $_POST['web_url_already'] . "\n";
$content .= "target_audience: " . $_POST['target_audience'] . "\n";
$content .= "Purpose: " . $_POST['purpose'] . "\n";
$content .= "Updated: " . $_POST['updated'] . "\n";
$content .= "rate: " . $_POST['rate'] . "\n";
$content .= "Comments " . $_POST['comments'] . "\n"; 

mail('myemailhere', 'Form submission', $content);
echo "<SCRIPT language=JavaScript>window.location.replace(\"iframe.html\")</SCRIPT>";
}

?>
If anyone has an idea what is wrong please tell me.
RJ
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

Try these to see if posted data exists:

Code: Select all

print_r($_POST);
//and also
print $content;
rjmxracer1
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 9:09 am

a bit confused

Post by rjmxracer1 »

I am a little new at this, where in the code should i put:

Code: Select all

print_r($_POST); 
	  print $content;
What will this tell me? Should i include the form HTML?
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

Like this: first print_r($_POST) to see if all the needed data is there. Especially SUBMIT:

Code: Select all

<?php
print_r($_POST);
if ($_POST['SUBMIT'] == 'Send the Data')
{
$content = "Name: " . $_POST['personal_name'] . "\n"; 
//and all the rest of it

//mail('myemailhere', 'Form submission', $content); comment out mailing
//echo "<SCRIPT language=JavaScript>window.location.replace(\"iframe.html\")</SCRIPT>";
print $content;
}
else print "There is no SUBMIT at post data";
?>
And then take a look at the source.
if there is no SUBMIT there is something wrong with the form you are submitting.
jmrdeuce32
Forum Newbie
Posts: 15
Joined: Wed Apr 27, 2005 5:45 pm
Location: Naples, FL

Post by jmrdeuce32 »

If the actual e-mailing is the problem you can try using PHPMailer....

Code: Select all

<?php 
$subject = 'Subject';
$mailcontent = 'Content';

require("c:\php\includes\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host     = "host";
$mail->SMTPAuth = true;
$mail->Username = "userName";
$mail->Password = "password";

$mail->From     ="me@somewhere.com";
$mail->FromName ="From Name";
$mail->AddAddress("address");  
$mail->IsHTML(true);
$mail->Subject  =  $subject;
$mail->Body     =  $mailcontent;

if(!$mail->Send())
{
   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   
}
?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Didnt really take a look at your code.

However i have some keywords for you to look up :)

mime
and
headers

Enjoy :)
Post Reply