Jump to content

FORM ISSUE!


verdipro

Recommended Posts

Hello, I am brand new to this forum & semi-new to PHP.  I am looking to enhance my PHP knowledge & hopefully help other fellow members when I can & it looks like I came to the right place to do both.

 

I am having an issue with a form that I have used on my PHP enabled sites.  It has worked on every server until this new server that I am posting this form on.  My web host tells me that this server is PHP4 in suexec mode (not sure what that means).

 

Below I have copied my code from my contact.php page.  When I submit the form I get the email, I even get the form field names, but the email contains none of the information that was typed into the form boxes.

 

<?

$msg = "Name:\t$_POST['name']\n";

$msg .= "Telephone:\t$_POST['phone']\n";

$msg .= "Email:\t$_POST['email']\n";

$msg .= "How do you wish to be contacted?:\t$_POST['contacted']\n";

$msg .= "Comments:\t$_POST['comments']\n";

$to = "[email protected]";

$subject = "Contact Us";

$mailheaders = "From: [email protected] <> \n";

mail($to, $subject, $msg, $mailheaders);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Web Site Title</title>

</head>

<body>

<meta http-equiv="Refresh" content="0; url=thankyou.htm">

</body>

</html>

 

If anyone has any ideas on what could be causing this issue, it would be greatly appreciated.  This has been a tough one for me to figure out.

Link to comment
https://forums.phpfreaks.com/topic/114317-form-issue/
Share on other sites

try

<?
$msg = "Name:\t$_POST[name]\n";
$msg .= "Telephone:\t$_POST[phone]\n";
$msg .= "Email:\t$_POST[email]\n";
$msg .= "How do you wish to be contacted?:\t$_POST[contacted]\n";
$msg .= "Comments:\t$_POST[comments]\n";
$to = "[email protected]";
$subject = "Contact Us";
$mailheaders = "From: [email protected] <> \n";
mail($to, $subject, $msg, $mailheaders);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Web Site Title</title>
</head>
<body>
<meta http-equiv="Refresh" content="0; url=thankyou.htm">
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587858
Share on other sites

It shouldn't since he is using the actual post values. Also the he has the correct way $_POST['name']. Best practice is to keep strings for array keys in single or double quotes.

 

But I guess on some servers you can call the array values right in the double quotes. I know it does not work on my server, I have to come out of the quotes or enclose them in brackets

$msg = "Name:\t{$_POST['name']}\n";

or

$msg = "Name:\t".$_POST['name']."\n";

 

Maybe someone can clarify this

 

On my box this works fine

 

$msg = "hello $name, how are you";

 

but this won't

 

$msg = "hello $_POST['name'], how are you";

 

Ray

 

 

Link to comment
https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587866
Share on other sites

Got ya, I figured that out when testing what you posted. Just goes all to hell if there is a space in the key. :)

 

That is why I will stick to keeping the quotes and brackets. Just makes me feel better. :)

 

Works

<?php
$_POST['name man'] = "Ray";
$msg = "Hello {$_POST['name man']} How are you";
echo $msg;
?>

 

no soup for you

<?php
$_POST['name man'] = "Ray";
$msg = "Hello $_POST[name man] How are you";
echo $msg;
?>

 

Ray

Link to comment
https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587883
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.