How to submit forms on other sites
Moderator: General Moderators
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
How to submit forms on other sites
How can I submit forms in php that are on other sites. for example, have a script that will fill out this post form and submit it.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
Code: Select all
<?php
$post_data = array();
$post_data['pictures[0]'] = "@cat.jpg";
$post_data['pictures[1]'] = "@dog.jpg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://my.domain.com/my_url.php" );
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);
print "$postResult";
?>-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
I'm having troubles with this code.
this is my test1.php file
this is my test.php file
send mail is included in includes.php. it doesnt send me no email. it just echo's the form.
this is my test1.php file
Code: Select all
<?php
$post_data = array();
$post_data['subject'] = "the subject";
$post_data['message'] = "the message";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.simsportal.net/test.php" );
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);
print "$postResult";
?>this is my test.php file
Code: Select all
<?
include("includes.php");
if(isset($_POST['Submit']))
send_mail("william@po2mob.com",$_POST['subject'],$_POST['message']);
?>
<form name="form1" method="post" action="">
<input name="subject" type="text" id="subject">
<br>
<input name="message" type="text" id="message">
<br>
<input type="submit" name="Submit" value="Submit">
</form>-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Count up the references to $_POST in your test script.
Now var_dump($_POST) in the test script. Notice anything missing?
Now var_dump($_POST) in the test script. Notice anything missing?
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
my new test1.php file
it dont think its posting cause i havn't received an email. if i fill the form out normally i get an email.
it dont think its posting cause i havn't received an email. if i fill the form out normally i get an email.
Code: Select all
<?php
$post_data = array();
$post_data['subject'] = "the subject";
$post_data['message'] = "the message";
$post_data['Submit'] = "Submit";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.simsportal.net/test.php" );
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);
print "$postResult";
?>-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am