Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass data to url that contain white space properly

Status
Not open for further replies.

TW00Si

MIS
Mar 4, 2003
4
US
Hello, I'm new to perl. Never seen it in my life till our ex-consultant bought a software for one of our website.

I need this piece of code (written half by the software creator and me) to pass data to a page I wrote in php.
<SCRIPT>
document.write('<a href=../updateschoolinfo.php?source=$data[schools.source]&pid=$data[schools.pid]&city=$data[schools.city]&state=$data[schools.state]&zip=$data[schools.zip]&phone=$data[schools.phone]&enrollment=$data[schools.enrollment] target=new>Update School Info</a>');
</SCRIPT>

The problem is, whenever there's a white space in any of the data field, the data following the 1st white space is cut off. How do I go about resolving this? I know I can use '+' for white space but how do I apply it here? And here's a piece from my php page that's getting the data.

<td><input name=&quot;mail_address&quot; size=&quot;35&quot; maxlength=&quot;35&quot; value=&quot;<?= $address ?>&quot;></td>

Any help will be greatly appreciated. Thanks in advance.

 
Thats not the correct route, you will catch the space but no other characters that are disallowed in a URL. Use CGI.pm

---
use CGI.pm;
$escaped_string = CGI::Util::escape(&quot;unescaped string&quot;);
---

This will ensure that you do not have bad stuff in your string. Do this to each element and THEN assemble your query string.

Another guy had a problem like this where the person who coded the query string assembly code did exactly what you are doing. He now has to maintain it and its a nightmare because the source string is never properly escaped.

Proper string escaping is critical.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top