•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,056 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,230 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1724 | Replies: 4
![]() |
•
•
Join Date: May 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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?
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?
•
•
Join Date: May 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: May 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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['subject']), ($messagetoadmin), 'From: '. $HTTP_POST_VARS['submitteremail']);
if ($HTTP_POST_VARS['ccsubmitter'] == 'yes')
{
mail($HTTP_POST_VARS['submitteremail'], 'Form Submitted: '. stripslashes($HTTP_POST_VARS['subject']), stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($_POST['autoresponse'] != '')
{
$body = geturl($autoresponse);
mail($submitteremail, 'Re: '. stripslashes($HTTP_POST_VARS['subject']), 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['thankspage']);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $HTTP_POST_VARS['thankspage'] .'">');
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"
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['subject']), ($messagetoadmin), 'From: '. $HTTP_POST_VARS['submitteremail']);
if ($HTTP_POST_VARS['ccsubmitter'] == 'yes')
{
mail($HTTP_POST_VARS['submitteremail'], 'Form Submitted: '. stripslashes($HTTP_POST_VARS['subject']), stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($_POST['autoresponse'] != '')
{
$body = geturl($autoresponse);
mail($submitteremail, 'Re: '. stripslashes($HTTP_POST_VARS['subject']), 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['thankspage']);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $HTTP_POST_VARS['thankspage'] .'">');
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"
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- need help! DAO + DataGridControl (Visual Basic 4 / 5 / 6)
- trying to remove extra white spaces in data file (Mac Users Lounge)
- Printing Variables (Python)
- Having Few Problems!! With this program?? (C)
- sorting 2d arrays (C)
Other Threads in the PHP Forum
- Previous Thread: Free PHP Support?
- Next Thread: mysqli + mysql functions (PHP5/MySQL 4.0)


Linear Mode