User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2005
Posts: 3
Reputation: clivey is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
clivey clivey is offline Offline
Newbie Poster

change spaces in fields submitted

  #1  
May 19th, 2005
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 28
Reputation: ashishjha54 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ashishjha54 ashishjha54 is offline Offline
Light Poster

Re: change spaces in fields submitted

  #2  
May 20th, 2005
do you want to replace spaces with some symbol or something else?
Reply With Quote  
Join Date: May 2005
Posts: 3
Reputation: clivey is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
clivey clivey is offline Offline
Newbie Poster

Re: change spaces in fields submitted

  #3  
May 20th, 2005
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!
Reply With Quote  
Join Date: May 2005
Posts: 28
Reputation: ashishjha54 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ashishjha54 ashishjha54 is offline Offline
Light Poster

Re: change spaces in fields submitted

  #4  
May 20th, 2005
instead of this
[PHP]$key = str_replace("_"," ",$key);[/PHP]
try using this
[PHP]$key = eregi_replace("_"," ",$key);[/PHP]
but this has to be used before the date is send by email.
Reply With Quote  
Join Date: May 2005
Posts: 3
Reputation: clivey is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
clivey clivey is offline Offline
Newbie Poster

Re: change spaces in fields submitted

  #5  
May 21st, 2005
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"
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC