CURL - Posting Data to page....

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
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

CURL - Posting Data to page....

Post by tecktalkcm0391 »

I have this HTML Code:

Code: Select all

<form action="http://s81.photobucket.com/albums/j224/****/" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <span class="panelUpload panelHalfWidth">
  <input type="hidden" name="addtype" id="img_addtype" value="local" />
  <input type="hidden" name="multi" id="img_multi" value="1" />
  <input type="hidden" name="listValidImageFiles" id="listValidImageFiles" value="gif, jpg, jpeg, png, bmp, swf" />
  <input type="hidden" name="media" value="image" />
  <!-- value(s): image|video -->
  <input type="hidden" name="action" value="addpic" />
  <label class="ltbluelabel"></label>
  </span>
  <p><span class="panelUpload panelHalfWidth"> </span><span class="visiblePanel">
    <input type="file" name="the_file[]" id="the_file1" size="30" class="floated" />
  </span></p>
  <p><span class="panelUpload panelHalfWidth">
    <input type="checkbox" name="preserve" id="preserve_img" value="true" checked="checked" />
  </span>Keep Name </p>
  <p>
    <label for="Submit"></label>
    <input type="submit" name="submitImgUpload" value="Submit" id="Submit">
  </p>
</form>

How can I make it submit the data, which is all in the PHP code, to the same page, but not having the user do anything?

If someone could help me or point me in the right direction, that would be awsome. All I have so far is:

Code: Select all

$post_data = $temp2;
			   
			  
			
			   $ch = curl_init();
			   curl_setopt($ch, CURLOPT_URL, "http://s81.photobucket.com/albums/j224/***/" ); 
			   curl_setopt($ch, CURLOPT_POST, 1 );
			   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
			   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			   $postResult = curl_exec($ch);
			
			   if (curl_errno($ch)) {
				   print curl_error($ch);
			   }
			   curl_close($ch);
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Re: CURL - Posting Data to page....

Post by PrObLeM »

you have to put all of the forum data into a string that looks like a qurey string ie.

$post_data = "var1=val1&var2=val2...etc";
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

so i just need to do something like a urlencode does for the string of vairables?
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

tecktalkcm0391 wrote:so i just need to do something like a urlencode does for the string of vairables?
yea, sure
Post Reply