Page 1 of 1

Form help PLEASE

Posted: Wed Apr 27, 2005 12:13 pm
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

Posted: Wed Apr 27, 2005 12:23 pm
by wwwapu
Try these to see if posted data exists:

Code: Select all

print_r($_POST);
//and also
print $content;

a bit confused

Posted: Wed Apr 27, 2005 12:39 pm
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?

Posted: Wed Apr 27, 2005 12:59 pm
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.

Posted: Wed Apr 27, 2005 8:02 pm
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;
   
}
?>

Posted: Thu Apr 28, 2005 12:02 am
by ol4pr0
Didnt really take a look at your code.

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

mime
and
headers

Enjoy :)