user10598595
user10598595

Reputation:

passing a value from get to a url

How do I pass the value from the variable $name1 (Let's say its bobsmith) to replace janedoe

<?php

$name1 = $_GET["name"];

$curl = curl_init();
$user = "user1";
$password = "pass1";
curl_setopt_array($curl, array(
CURLOPT_URL =>'https://betawebservices.whatever.com/login/service/v4/SchemaData/INDIVIDUAL- 
ACTIVITIES-University/USERNAME:janedoe/',

I was hoping that I could say

<?php

$name1 = $_GET["name"];

$curl = curl_init();
$user = "user1";
$password = "pass1";
curl_setopt_array($curl, array(
CURLOPT_URL=>'https://betawebservices.whatever.com/login/service/v4/SchemaData/INDIVIDUAL- ACTIVITIES-University/USERNAME:$name1/',

...but that doesnt work. Thanks

Upvotes: 0

Views: 38

Answers (2)

Kandy
Kandy

Reputation: 673

This will work..

CURLOPT_URL=>'https://betawebservices.whatever.com/login/service/v4/SchemaData/INDIVIDUAL- ACTIVITIES-University/USERNAME:'.$name1.'/'

Upvotes: 0

Michael Miller
Michael Miller

Reputation: 399

That should work fine if you place the contents of CURLOPT_URL in double quotes instead of single quotes.

Upvotes: 1

Related Questions