When I send my form to my email address using php everything comes out great apart from the Field names that had spaces in them like user first name becomes user_first_name

Is there a way to put the spaces back in as this is very important as the email goes into some software that doesnt like _!!!!!

Any Ideas is there a key or symbol to use instead of space that would represent a space to PHP?

do you want to replace spaces with some symbol or something else?

the field names are called things like "name first", when I submit the form, it changes the field name to "name_first".
I need a command to put in the php file to change them back from _ to spaces.
I have only just started with PHP, the file I have has lines in it which I think I need to change below:


";
while(list($key, $value) = each($HTTP_POST_VARS))
{
if (!stristr($controlvars, ' '. $key .' '))
{
$messagetoadmin .= $key .': '. $value .'
';
$messagetosubmitter .= $key .': '. $value .'
';
$key = str_replace("_"," ",$key);
}
}

sure its something like string replace command but not sure how it goes!

instead of this

$key = str_replace("_"," ",$key);

try using this

$key = eregi_replace("_"," ",$key);

but this has to be used before the date is send by email.

still no good, but I am not sure where to put that line, the line I had there was only put in as a test, not even sure if it was the right part of the php file to put it into.

here is the whole form unedited so if you can help please feel free!:


<?php
error_reporting(0);
$adminemail = 'clivesmith1978@hotmail.com ';

$version = '1.10';
$controlvars = ' thankspage submitteremail ccsubmitter ';
$messagetoadmin = $HTTP_POST_VARS ." Action: Create HD


";
$messagetosubmitter = "You have submitted a form with the content listed below. Your submission will be reviewed, please be patient in awaiting a response.


";
while(list($key, $value) = each($HTTP_POST_VARS))
{
if (!stristr($controlvars, ' '. $key .' '))
{
$messagetoadmin .= $key .': '. $value .'
';
$messagetosubmitter .= $key .': '. $value .'
';

}
}
mail($adminemail, 'Fault Submitted: '. stripslashes($HTTP_POST_VARS), ($messagetoadmin), 'From: '. $HTTP_POST_VARS);

if ($HTTP_POST_VARS == 'yes')
{
mail($HTTP_POST_VARS, 'Form Submitted: '. stripslashes($HTTP_POST_VARS), stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($_POST != '')
{
$body = geturl($autoresponse);
mail($submitteremail, 'Re: '. stripslashes($HTTP_POST_VARS), stripslashes($body), 'From: '. $adminemail);
}

$url = "http://80.8888/mail/thankspage.html"; // target of the redirect
$delay = "3"; // 3 second delay

echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';

header('Location: '. $HTTP_POST_VARS);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $HTTP_POST_VARS .'">');
function geturl($url)
{
if (version_compare("4.3.0", phpversion(), "<"))
{
$filecontents = @file_get_contents($url);
}
else
{
$fd = @fopen($url, 'rb');
$filecontents = @fread ($fd, 30000000);
@fclose ($fd);
}
return $filecontents;
}
$url = "http://80.88888888/mail/thankspage.html";
?>

By the way the thing that is the problem is the field names that have spaces in them like "full name" comes out in the email like "full_name"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.