im wondering if someone can help me out. what imloking to do is have a contact form that people can fill in etc, this is then email to me thought my site. etc

this i can do etc and have working.

i have the expanded this so that i get a lick in the email sent to me that links to multimap with there postcode supplied so i can see where the person who contacted me lives etc.

this all works fine, how ever if users dont enter the postcode like AB123CD and enter it like AB12 3CD then the link dont work.

can php be used to remove the space if someone enters one??

my form works as such i have a contact page with a farm, when submitted goes to a a sendmail.php page that sends the mail and goes to a thank you page.

here is my sendmail.php code

<?php

  $name = $_REQUEST['name'] ;
  $address = $_REQUEST['address'] ;
  $postcode = $_REQUEST['postcode'] ;
  $tel = $_REQUEST['tel'] ;
  $email = $_REQUEST['email'] ;
  $find = $_REQUEST['find'] ;
  $enquiry = $_REQUEST['enquiry'] ;

$message = "You have been contacted through your website www.mysite.co.uk

Supplied information

Name: $name
Address: $address
Postcode: $postcode 
Telephone number: $tel 
Email address: $email

Found the Website Via $find 

Enquiry: 
$enquiry

click here for a map of to there location
http://www.multimap.com/map/browse.cgi?pc=$postcode
(map only works if contact suppled a postcode)";

ini_set("sendmail_from", "root@localhost.co.uk");
mail("myemail@me.com", "Website Enquiry", "$message", "From: Website Enquiry");

header( "Location: http://www.mysite.co.uk/thankyou.php" ); 

?>
    $string = 'This string has spaces in it';
    echo str_replace(' ', '', $string);
    

      Alternatively, you can use [man]rawurlencode/man or [man]urlencode/man on the variable before appending it to the query string of the link's URL.

        and where would i use these in my case??

          $postcode = rawurlencode($_REQUEST['postcode']);

          Of course, remember to check for the existence of incoming variables with [man]isset[/man] or [man]empty[/man] before using them.

            will this screw up if the user doesn't add a postcode?

              Yes, but so will all your other incoming variables, which is why you have to check.

                Write a Reply...