我一直在寻找几个小时,但我仍然不清楚HTTPPost
方法。我有这样的代码......
httpclient = new DefaultHttpClient();
httppost = new HttpPost(url);
// Add your data
Log.i("ACTIVITY","PostInfo");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("email", stringeditemail));
httppost.setEntity(new UrlEncodedFormEntity(pairs));
这是否应该将信息从指定站点发布到给定的 php?如果是这样,我做错了什么没有发布?
这是我的 PHP
<?php
require('include/config.php');
require('include/function.php');
require('classes/captcha.class.php');
require('language/' .$_SESSION['language']. '/signup.lang.php');
if ( $config['user_registrations'] == 0 ) {
$msg = $lang['signup.registration_disabled'];
session_write_close();
header('Location: index.php?msg=' .$msg);
die();
}
$email = NULL;
if ( isset($_REQUEST['action_signup']) && $_REQUEST['action_signup'] != '' )
{
$email = $filterObj->process(trim($_POST['email']));
if( $email == '' )
$err = $lang['signup.email_empty'];
elseif ( !check_email($email) )
$err = $lang['signup.email_invalid'];
elseif ( check_field_exists($email, 'email', 'signup') == 1 )
$err = $lang['signup.email_exists'];
$_REQUEST['pack_id'] == '' )
$err = $lang['signup.select_package'];
if ( $err == '' ) {
$email = mysql_real_escape_string($email);
$sql = "insert into signup set email='" .$email. "';
$conn->execute($sql);
if( $config['enable_package'] == 'yes' ) {
$pack_id = mysql_real_escape_string($_REQUEST['pack_id']);
$sql = "select * from package where pack_id='" .$pack_id. "'";
$rs = $conn->execute($sql);
} else {
$sql = "update signup set acount_status='Inactive' where UID='" .$userid. "' limit 1";
$conn->execute($sql);
session_write_close();
header("Location: pack_ops.php?pack=$_REQUEST[pack_id]&uid=".base64_encode($userid));
die();
}
}
$sql = "INSERT INTO users_online (UID, online) VALUES (" .$userid. ", " .time(). ")";
$conn->execute($sql);
$_SESSION['EMAIL'] = $_REQUEST['email'];
$ran=time().rand(1,99999999);
$sql="update verify as v, signup as s set v.vcode='" .$ran. "', s.emailverified='no' WHERE v.UID=s.UID and v.UID='" .$userid. "'";
$conn->execute($sql);
STemplate::assign('vcode',$ran);
$to = $_SESSION['EMAIL'];
$name = $config['site_name'];
$from = $config['admin_email'];
$rs = $conn->execute("select * from emailinfo where email_id='verify_email'");
$subj = $rs->fields['email_subject'];
$email_path = $rs->fields['email_path'];
$mailbody = STemplate::fetch($email_path);
mailing($to,$name,$from,$subj,$mailbody);
$_SESSION['verification_sent'] = $lang['signup.verification_sent'];
$redirect = ( isset($_SESSION['redirect']) && $_SESSION['redirect'] != '' ) ? $_SESSION['redirect'] : $config['BASE_URL'];
$_SESSION['redirect'] = NULL;
session_write_close();
header('Location: ' .$redirect);
die();
}
}
if ( $config['enable_package'] == 'yes' ) {
$sql = "select * from package where status = 'Active' order by price desc";
$rs = $conn->execute($sql);
STemplate::assign('package', $rs->getrows());
}
STemplate::assign('err',$err);
STemplate::assign('msg',$msg);
STemplate::assign('head_bottom',"homelinks.tpl");
STemplate::assign('username', $username);
STemplate::assign('email', $email);
STemplate::display('head1.tpl');
STemplate::display('err_msg.tpl');
STemplate::display('signup.tpl');
STemplate::display('footer.tpl');
STemplate::gzip_encode();
?>