Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox NOT submitting/capturing form values 1

Status
Not open for further replies.

jollydonkey

Technical User
Sep 5, 2008
23
CA
Hello,

I have a PHP form processing script that captures various form fields and submits them via email.

The script is working in IE and Opera without issues. In Firefox and Netscape, the script executes, however, none of the values inputed in the form get captured.

Why is this? If it helps, I'm using POST and enctype="multipart/form-data" as the form tag attributes.

Any thoughts? Does it matter if in my PHP script, variable names are enclosed in double or single quotes? For example:

$subject = "$topic"; vs $subject = '$topic';

Thanks!

Cheers,
Dipesh.
 
variables are not expanded within single quotes. This has nothing to do with the browser.

other than this, you are not giving us enough information to help debug. php is not dependent on browsers however.
 
Thanks - here is the code:

Code:
$email  = $_POST['email'];
$cc     = $_POST['cc'];
$ccCopy = $cc.",".$email;
$topic = $_POST['topic'];
$summary = $_POST['summary'];

$topic_output = stripslashes($topic);
$summary_output = stripslashes($summary);

$to = 'me@me.com';
$subject = "$topic_output";
$message = $summary_output;

$headers = array('From' => $email, 'To' => $to, 'CC' => $ccCopy, 'Subject' => $subject);

$host = "smtp.server.com";
$username = "me@me.com";
$password = "password";

$smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $message);

Thanks in advance for the help/guidance!

 
what mailer class are you using?

and I note that you are not doing any validation on the inputs.
 
I'm using PEAR's mail on a windows platform. Granted, it's not the best looking script :) I'm stumped.

Also, a special thank you - your help on this and other posts have helped me learn PHP.

Cheers,
D.
 
OK. i would not normally advocate departing from an abstraction layer like PEAR::Mail but for debugging purposes it's worth doing.

first off let's see what's actually happening. please run this code and let us know what happens. make sure that the $to variable is set to your email address!

Code:
function cleanse ($var){
 if (get_magic_quotes_gpc()){ $var = stripslashes($var); }
 $var = trim($var);
 return $var;
}
function validateEmail($email){
 return preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/', $email);
}
function validateSubject($subject){
 $pairs = array ("\r\n"=>'', "\r"=>'', "\n"=>'');
 $subject = strtr($subject, $pairs);
 return htmlspecialchars($subject);
}
//undo magic quotes
array_walk($_POST, 'cleanse');


$email  = validateEmail($_POST['email']) ? $_POST['email'] : FALSE;
$cc     = validateEmail($_POST['cc']) ? $_POST['cc'] : FALSE;
if (!$email || !$cc) die('illegal characters in either one or more email addresses provided.  Probably malicious attempt.");

$ccCopy = "$cc, $email";

$subject = cleanseSubject($_POST['topic']);
$message = $_POST['summary'];
$to = 'me@me.com';

$result = mail ($to, $subject, $message, "cc:  $ccCopy\r\nFrom: $email \r\nReply-to: $email\r\n");

if ($result) {
 echo "email properly submitted to mail handler";
} else {
 echo "error in submitting mail to handler";
}
/*
$headers = array('From' => $email, 'To' => $to, 'CC' => $ccCopy, 'Subject' => $subject);

$host = "smtp.server.com";
$username = "me@me.com";
$password = "password";

$smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $message);
*/
 
Wow - let me study this revision late tonight and I'll let you know what happens :)

Again, thank you so much.

Cheers,
Dipesh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top