Passing URL varibles combined using get and/or hyperlinks

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
jbstone713
Forum Newbie
Posts: 14
Joined: Wed Mar 02, 2005 10:01 pm

Passing URL varibles combined using get and/or hyperlinks

Post by jbstone713 »

This is part of what I need my url to pass:

//http://test.php?faxnumber%5B%28555%29+2 ... ubmit=Next

However I also need to pass the following:

company=$name&address=$street&city=$city&state=$state&zip=$zip


Is there any way to combine the following so that it passes all variables?

1:
company=$name&address=$street&city=$city&state=$state&zip=$zip

2:
faxnumber%5B%28555%29+222-8900%5D=%28555%29+222-8900&submit=Next\">Add To Favorites</A>");


The following does not work:
//print ("<A HREF=\"$REQUEST_URI?company=$name&address=$street&city=$city&state=$state&zip=$zip \">Add To Favorites</A>");

Any Suggestions?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

rawurlencode() each variable.. then..

Code: Select all

echo '<a href="' . $_SERVER&#1111;'PHP_SELF'] . '?company=' . $name . '&address=' . $street .. and so on . 'faxnumber%5B%28555%29+222-8900%5D=%28555%29+222-8900&submit=Next">Add to Favorites</a>';
:?
jbstone713
Forum Newbie
Posts: 14
Joined: Wed Mar 02, 2005 10:01 pm

rawurlencode() each variable

Post by jbstone713 »

How do I rawurlencode() each variable when they are in an array? Is there a way to make the checkboxes be on without having to press submit (just check it) Please have a look at my code. I've never used rawurlencode() before. I looked at some examples, but I am still confused.

Code: Select all

print ("<form name=info method=get action=?php_self.php>");

while ($row2 = mysql_fetch_array($result2))&#123;

$contact_first = $row2&#1111;"sales_contact_first_name"];
$contact_last = $row2&#1111;"sales_contact_last_name"];
$contact = "$contact_first $contact_last";
$name = $row2&#1111;"company_name"];
$number = $row2&#1111;"sales_phone_number"];
$street = $row2&#1111;"street_address"];
$city = $row2&#1111;"sales_city"];
$state = $row2&#1111;"sales_state"];
$zip = $row2&#1111;"sales_zip"];
$fax = $row2&#1111;"sales_fax_number"];
$id = $row2&#1111;"user_id"];
$all = "<B>$name</B><BR>Contact: $contact<BR>$street<BR>$city, $state $zip<BR>Phone: $number<BR>Fax: $fax";
////////////////////////////////////////////////////////////////
// Prints out all of the company information, a checkbox, etc.//

print("<input type=checkbox name="faxnumber&#1111;$fax]" value="$fax""); 
if($faxnumber&#1111;$fax] == "$fax")&#123;
print ("checked>");
&#125;

print ("<B>$name</B>");
print ("<BR>");
print ("&nbsp&nbsp&nbsp&nbsp&nbsp$street");
print ("<BR>");
print ("&nbsp&nbsp&nbsp&nbsp&nbsp$city, $state $zip");
print ("<BR>");
print ("&nbsp&nbsp&nbsp&nbsp&nbspPhone: $number");
print ("<BR>");
print ("&nbsp&nbsp&nbsp&nbsp&nbspFax: $fax");
print ("<BR>");

print ("&nbsp&nbsp&nbsp&nbsp&nbsp<A HREF="http://www.mapquest.com/maps/map.adp?searchtype=address&country=US&addtohistory=&searchtab=home&address=$street&city=$city&state=$state&zipcode=$zip" target="_blank">Get Map</A>");


//print ("&nbsp&nbsp&nbsp&nbsp&nbsp<A HREF="$REQUEST_URI">Add To Favorites</A>");

echo '<a href="' . $_SERVER&#1111;'PHP_SELF'] . '?company=' . $name . '&address=' . $street .. and so on . 'faxnumber%5B%28555%29+222-8900%5D=%28555%29+222-8900&submit=Next">Add to Favorites</a>';
jbstone713
Forum Newbie
Posts: 14
Joined: Wed Mar 02, 2005 10:01 pm

Got it!!

Post by jbstone713 »

Thanks anyway. I got it!
Post Reply