0

The following code doesn't work as I expected...

curl_setopt($ch, CURLOPT_POSTFIELDS, "password="+$alphas[$x]+"&submit=yes");

The $alphas[$x] part doesn't seem to work by putting the letter in the string. A couple lines below that I echo $alphas[$x] and that works perfectly.

For example, if I change the first line of code to...

curl_setopt($ch, CURLOPT_POSTFIELDS, "password=j&submit=yes");

It works perfectly as expected, so therefore I think $alpahs[$x] isn't putting the letter in the string like it should.

$content = "7";
$x = 0;
$alphas = array_merge(range("A", "Z"), range("a", "z"));

while($x < 52) {
print_r($alphas[$x]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "/Demo/form.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "password="+$alphas[$x]+"&submit=yes");
$content=curl_exec($ch);

echo $content;
echo "Pass: ";
echo $alphas[$x];
echo "<br>";
$x++;

}

2 Answers 2

3

The period is the string concatenation operator, not the plus sign:

curl_setopt($ch, CURLOPT_POSTFIELDS, "password=".$alphas[$x]."&submit=yes");
Sign up to request clarification or add additional context in comments.

Comments

0

You can also insert variables into a double-quoted string using the following syntax:

curl_setopt($ch, CURLOPT_POSTFIELDS, "password={$alphas[$x]}&submit=yes");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.