hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : dumb php question help
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

dumb php question help

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-18-2005, 05:29 PM
hoachen hoachen is offline
WHT Addict
 
Join Date: Jun 2005
Posts: 146

dumb php question help


I am doing a form that users fill in the form and submit it and this form will send to my email inbox. I have a problem on selection option on the form and php
for example html form will look like

<td width="44%" height="30"><select name="Food" size="1">
<option selected>Select One</option>
<option value="../food/western.htm" >Western Food</option>
<option value="../food/italian.htm" >Italian Food</option>
<option value="../food/western.htm" >Asian Food </option>


php code

$Message .= "Food: " . $_POST["food"] . "\n";

in my mailbox will look like this

Food: ../food/western.htm

HOW DO I GET RID OF THE ../FOOD/WESTERN.HTM AND JUST PRINT WESTERN FOOD?

I know it is easy for you as an expert but it is not easy for me. Please give you advise and opinion.

Reply With Quote


Sponsored Links
  #2  
Old 11-18-2005, 05:51 PM
malenski malenski is offline
Junior Guru Wannabe
 
Join Date: Nov 2005
Location: Buffalo
Posts: 94
Dumb Answer

Quote:
Originally Posted by hoachen
<td width="44%" height="30"><select name="Food" size="1">
<option selected>Select One</option>
<option value="../food/western.htm" >Western Food</option>
<option value="../food/italian.htm" >Italian Food</option>
<option value="../food/western.htm" >Asian Food </option>
Should be

<td width="44%" height="30"><select name="Food" size="1">
<option selected>Select One</option>
<option value="Western Food" >Western Food</option>
<option value="Italian Food" >Italian Food</option>
<option value="Asian Food" >Asian Food </option>

Yes its a dumb answer - but you haven't said if you need the old values.

Reply With Quote
  #3  
Old 11-18-2005, 06:53 PM
mmarinsen mmarinsen is offline
Disabled
 
Join Date: Nov 2005
Location: Singapore
Posts: 6
easiest

In fact, if you don't need the old values, then you could simplify even further. The text of the option (between the <OPTION> </option> tags) will become the default value if you don't specify a value inside <OPTION Value="HERE">.

So this would work, in theory:

<select name="Food" size="1">
<option selected>Select One</option>
<option>Western Food</option>
<option>Italian Food</option>
<option>Asian Food </option>
</select>

Reply With Quote
Sponsored Links
  #4  
Old 11-18-2005, 07:00 PM
orbitz orbitz is offline
Web Hosting Master
 
Join Date: Mar 2004
Posts: 1,301
what if hoachen didn't want to change the value of those options?

- if that the case, then you can use regular expression method or str_replace to take out just the name of the file without the extension; then make the name with all capital letters; finally, concatinate it with the word "FOOD" --> and send to your email

Reply With Quote
  #5  
Old 11-19-2005, 03:53 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
PHP Code:
<?php

  $food_name 
strtoupper(basename($_POST['Food'],'.htm')).' FOOD';
  echo 
$food_name;

?>

Reply With Quote
  #6  
Old 11-19-2005, 08:14 AM
hoachen hoachen is offline
WHT Addict
 
Join Date: Jun 2005
Posts: 146
orbitz is right I don't want to put value "option value=" here" is because, when i click on the selection it will bring me to another page. Yes, I only want it to send to my mail box not to echo. Orbitz, you suggested to put reg to trim it off but where(which part) i should do the reg? any suggestion?

I try it this way
$food = ._$POST['food'];
$new_food = ereg_replace("../food/*.htm", I don't know how to put here, $food));

$Message.= $new_food;

I just want to replace the "../food/.htm" where the *astrick is what i want to print it on my mailbox.

fyrestrtr, first thank you for your code, I try it and it didnt work. I don't want to echo anything and don't really understand what is "strtoupper(basename" Well, I will check it on the web later.



thank you guys for your suggestion.

Reply With Quote
  #7  
Old 11-19-2005, 08:27 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
Well you have to edit it to suit your situation. I'll give you an example of what it will do here:

PHP Code:
$_POST['food'] = '../this/is/a/long/directory/to/show/you/how/it/works/apple.htm';
echo 
strtoupper(basename($_POST['food'],'.htm')).' FOOD'
You if you run that code, you will get as output :

APPLE FOOD

Look up the functions to see what they do. There really isn't any need to get involved in regular expressions for something as simple as this

Reply With Quote
  #8  
Old 11-19-2005, 09:52 AM
orbitz orbitz is offline
Web Hosting Master
 
Join Date: Mar 2004
Posts: 1,301
that's good to know- I haven't used basename() before. it really makes it simple.

Thanks!

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Joomla Hosting Study Shows Speed, Uptime Top Selling Points of a Web Host Web Hosting News 2012-11-07 15:06:36
Zetta Launches Appliance-Free Hybrid Smart Cloud Backup Solution Web Hosting News 2012-10-23 16:29:27
Big Data – Privacy Threat or Business Model Blog 2012-03-19 23:07:05
Rackspace Blog Looks at Easy Outsourcing for App Development Blog 2012-03-05 19:07:48
Blackberry the UnCloud Blog 2011-10-14 15:28:54


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?