Jump to content

Form field value into Curl function?


jax0n

Recommended Posts

How do I get the $code variable value into the Function from the Form textbox

if that textbox "name" field value is pulled from my Db and not always the same.

thx..

--------------------------------------------

<?php

 

require_once("db.php");

 

$sql = "SELECT * FROM table";

$res = mysql_query($sql);

 

while($row = mysql_fetch_array($res)) {

$vals["url"] = $row['url'];

$vals["name"] = $row['name'];

 

?>

<form action="<?php echo $row['url'];?>" method="post">

  <input type="text" name="<?php echo $row['name'];?>">

  <input type="submit" name="submits" value="Submit">

</form>

<?php

  if(isset($_POST["submits"])) {

  post_form($vals);

  }

}

 

function post_form($vals) {

$url = $vals["url"];

 

$code = "(this is the value I need to get from the FORM TEXTBOX above)";

 

$ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, $url);

  curl_setopt($ch, CURLOPT_POST, 1);

  curl_setopt($ch, CURLOPT_POSTFIELDS, array('url'=>$url, 'code'=>$code, 'submit'=>'Submit'));

 

$result = curl_exec($ch);

  print($result);

  curl_close($ch);

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/163930-form-field-value-into-curl-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.