Forms - replaceing spaces " " with +

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Forms - replaceing spaces " " with +

Post by josh »

You know when you submit a form it changes all spaces to +


well I am reading contents from a database, $title $price, and $kind


well im out putting them to a table and I want another column available? so now i have added that and when i goto my page it shows it and it works, I made the variable $available into a link similar to the following

Code: Select all

echo("<tr><td width>$name</td><td>$age</td><td>Fiction</td><td>Non-Fiction</td><td><a href=email.php?name=$name&price=$age&cat=fiction>Available - yes</a></td></tr>\n");
and it outputs exactly what i told it to but when you click the link it goes to email.php which looks like this:

Code: Select all

<?
    $name = $_REQUEST['name'] ;
	$price = $_REQUEST['price'] ;
	$cat = $_REQUEST['cat'] ;
	
		echo("You have selected to purchase the book titled $name which will charge you a total of $price , it is a $cat book");

	
?>
And when I click the original link, since there is spaces in the variable $title only the first word of the title shows up on email.php and the rest of the variables are excluded


Would I replace spaces with a + when I printed the available? link originally or what?
?>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

$bob=str_replace(" ", "+", $bob); deletes spaces and replaces them with + but when i do this:






//put title into temp variable to delete spaces from
$name2=$name;
$name2=str_replace(" ", "+", $name2);
// If so display it to the user
echo("<tr><td>$name</td><td>$age</td><td>Non-Fiction</td><td><a href=email.php?name=$name2&price=$age&cat=nonfiction>Available - yes</a></td></tr>\n");









it gives same error
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

nvm i got it
Post Reply