我们有一个由wordpress提供支持的网站。
我们希望在我们的一个页面中包含一个表格,客户可以从清单html表格中选择产品,然后弹出窗口,客户输入他的姓名/地址/电子邮件等。
这个信息&所选产品的最终价格将用于在WHMCS中创建新客户&然后为此客户创建发票
我已经尝试了很多,但我不知道问题出在哪里。
我在WHMCS安全标签中有列入白名单远程服务器的IP地址
我已经打开了php错误显示,但没有显示任何内容
我还检查过,如果远程服务器通过API成功连接。一切似乎都很好。但仍然没有运气
它只是显示:
发生错误。请联系支持。 ()
这是我目前正在处理的代码:
<?php
$whmcsurl = "http://www.yourdomain.com/whmcsfolder/";
$apiusername = "adminuser"; # Admin username goes here
$apipassword = "password"; # Admin password goes here
if ($_POST["action"]=="submit") {
# Get Values
$domain = trim(htmlentities($_POST["domain"]));
$domaintype = trim(htmlentities($_POST["domaintype"]));
$pid = trim(htmlentities($_POST["pid"]));
$billingcycle = trim(htmlentities($_POST["billingcycle"]));
$firstname = trim(htmlentities($_POST["firstname"]));
$lastname = trim(htmlentities($_POST["lastname"]));
$companyname = trim(htmlentities($_POST["companyname"]));
$email = trim(htmlentities($_POST["email"]));
$address1 = trim(htmlentities($_POST["address1"]));
$address2 = trim(htmlentities($_POST["address2"]));
$city = trim(htmlentities($_POST["city"]));
$state = trim(htmlentities($_POST["state"]));
$postcode = trim(htmlentities($_POST["postcode"]));
$country = trim(htmlentities($_POST["country"]));
$phonenumber = trim(htmlentities($_POST["phonenumber"]));
$password = trim(htmlentities($_POST["password"]));
$password2 = trim(htmlentities($_POST["password2"]));
$paymentmethod = trim(htmlentities($_POST["paymentmethod"]));
$tosagreement = $_POST["tosagreement"];
# Error Checking
if (!$domain) {
$errors[] = "You did not enter a domain name";
}
if (ereg('[^a-z0-9.-]', $domain)) {
$errors[] = "The domain you entered is not valid";
}
if (($billingcycle!="monthly")AND($billingcycle!="annually")) {
$billingcycle = "monthly";
}
if (!$firstname) {
$errors[] = "You did not enter your first name";
}
if (!$lastname) {
$errors[] = "You did not enter your last name";
}
if (!$email) {
$errors[] = "You did not enter your email address";
} elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email)) {
$errors[] = "The email address you entered is invalid";
}
if (!$address1) {
$errors[] = "You did not enter the first line of your address";
}
if (!$city) {
$errors[] = "You did not enter your city";
}
if (!$state) {
$errors[] = "You did not enter your state";
}
if (!$postcode) {
$errors[] = "You did not enter your postcode";
}
if (!$country) {
$errors[] = "You did not enter your country";
}
if (!$phonenumber) {
$errors[] = "You did not enter your phone number";
}
if (!$password) {
$errors[] = "You must enter a password";
} elseif ($password!=$password2) {
$errors[] = "The password you entered did not match";
}
if (!$tosagreement) {
$errors[] = "You must agree to the terms of service";
}
if (!$errors) {
# Submit Order
$apiurl = $whmcsurl."includes/api.php"; # URL to WHMCS API file
$postfields = array();
$postfields["username"] = $apiusername;
$postfields["password"] = md5($apipassword);
$postfields["action"] = "addclient";
$postfields["firstname"] = $firstname;
$postfields["lastname"] = $lastname;
$postfields["companyname"] = $companyname;
$postfields["email"] = $email;
$postfields["address1"] = $address1;
$postfields["address2"] = $address2;
$postfields["city"] = $city;
$postfields["state"] = $state;
$postfields["postcode"] = $postcode;
$postfields["country"] = $country;
$postfields["phonenumber"] = $phonenumber;
$postfields["password2"] = $password;
$query_string = "";
foreach ($postfields AS $k=>$v) {
$query_string .= "$k=".urlencode($v)."&";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
$data = curl_exec($ch);
curl_close($ch);
$data = explode(";",$data);
foreach ($data AS $temp) {
$temp = explode("=",$temp);
$results[$temp[0]] = $temp[1];
}
if ($results["result"]=="success") {
$clientid = $results["clientid"];
} else {
die("An error occured. Please contact support. ({$results['message']})");
}
$postfields = array();
$postfields["username"] = $apiusername;
$postfields["password"] = md5($apipassword);
$postfields["action"] = "addorder";
$postfields["clientid"] = $clientid;
$postfields["pid"] = $pid;
$postfields["domain"] = $domain;
if (($domaintype=="register")OR($domaintype=="transfer")) {
$postfields["domaintype"] = $domaintype;
$postfields["regperiod"] = 1;
}
$postfields["billingcycle"] = $billingcycle;
$postfields["paymentmethod"] = $paymentmethod;
$query_string = "";
foreach ($postfields AS $k=>$v) {
$query_string .= "$k=".urlencode($v)."&";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
$data = curl_exec($ch);
curl_close($ch);
$data = explode(";",$data);
foreach ($data AS $temp) {
$temp = explode("=",$temp);
$results[$temp[0]] = $temp[1];
}
if ($results["result"]=="success") {
$invoiceid = $results["invoiceid"];
header("Location: ".$whmcsurl."dologin.php?username=$email&password=$password&goto=viewinvoice&id=$invoiceid");
exit;
} else {
die("An error occured. Please contact support. ({$results['message']})");
}
}
}
?><html>
<head>
<title>Order Form</title>
</head>
<body>
<h1>Order Form</h1>
<?php
if ($errors) {
echo "<p>The following errors occured.</p><ul>";
foreach ($errors AS $error) {
echo "<li>$error</li>";
}
echo "</ul>";
}
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<input type="hidden" name="action" value="submit" />
<table>
<tr><td width="150"><b>Domain Details</b></td></tr>
<tr><td>Domain Name</td><td>www. <input type="text" name="domain" size="40" value="<?php echo $domain ?>" /> (eg. mydomain.com)</td></tr>
<tr><td>Domain Type</td><td>
<input type="radio" name="domaintype" value="register"<?php if (($domaintype=="register")OR(!$domaintype)) { echo " checked"; } ?> /> I want to register this as a new domain<br />
<input type="radio" name="domaintype" value="transfer"<?php if ($domaintype=="transfer") { echo " checked"; } ?> /> I already own this domain and want to transfer it to you<br />
<input type="radio" name="domaintype" value="owndomain"<?php if ($domaintype=="owndomain") { echo " checked"; } ?> /> I own this domain and will change the nameservers at my existing registrar</td></tr>
<tr><td><br /></td></tr>
<tr><td><b>Hosting Details</b></td></tr>
<tr><td>Hosting Package</td><td>
<input type="radio" name="pid" value="1"<?php if (($pid=="1")OR(!$pid)) { echo " checked"; } ?> /> Starter Package
<input type="radio" name="pid" value="2"<?php if ($pid=="2") { echo " checked"; } ?> /> Standard Package
<input type="radio" name="pid" value="3"<?php if ($pid=="3") { echo " checked"; } ?> /> Advanced Package
</td></tr>
<tr><td>Billing Cycle</td><td><select name="billingcycle"><option value="monthly"<?php if ($billingcycle=="monthly") { echo " selected"; } ?>>Monthly</option><option value="annually"<?php if ($billingcycle=="annually") { echo " selected"; } ?>>Annually</option></select></td></tr>
<tr><td><br /></td></tr>
<tr><td><b>Your Details</b></td></tr>
<tr><td>First Name</td><td><input type="text" name="firstname" size="30" value="<?php echo $firstname ?>" /></td></tr>
<tr><td>Last Name</td><td><input type="text" name="lastname" size="30" value="<?php echo $lastname ?>" /></td></tr>
<tr><td>Company Name</td><td><input type="text" name="companyname" value="<?php echo $companyname ?>" size="30" /></td></tr>
<tr><td>Email Address</td><td><input type="text" name="email" value="<?php echo $email ?>" size="30" /></td></tr>
<tr><td>Address 1</td><td><input type="text" name="address1" value="<?php echo $address1 ?>" size="30" /></td></tr>
<tr><td>Address 2</td><td><input type="text" name="address2" value="<?php echo $address2 ?>" size="30" /></td></tr>
<tr><td>City</td><td><input type="text" name="city" size="30" value="<?php echo $city ?>" /></td></tr>
<tr><td>State</td><td><input type="text" name="state" size="30" value="<?php echo $state ?>" /></td></tr>
<tr><td>Postcode</td><td><input type="text" name="postcode" size="30" value="<?php echo $postcode ?>" /></td></tr>
<tr><td>Country</td><td><input type="text" name="country" size="30" value="<?php echo $country ?>" /></td></tr>
<tr><td>Phone Number</td><td><input type="text" name="phonenumber" size="30" value="<?php echo $phonenumber ?>" /></td></tr>
<tr><td>Payment Method</td><td>
<input type="radio" name="paymentmethod" value="paypal"<?php if (($paymentmethod=="paypal")OR(!$paymentmethod)) { echo " checked"; } ?> /> PayPal
<input type="radio" name="paymentmethod" value="authorize"<?php if ($paymentmethod=="authorize") { echo " checked"; } ?> /> Credit Card
</td></tr>
<tr><td>Password</td><td><input type="password" name="password" size="30" /></td></tr>
<tr><td>Confirm Password</td><td><input type="password" name="password2" size="30" /></td></tr>
</table>
<p align="center"><input type="checkbox" name="tosagreement" /> I have read and agree to the <a href="http://www.yourdomain.com/terms.html" target="_blank">Terms of Service</a></p>
<p align="center"><input type="submit" value="Submit Order" /></p>
</form>
</body>
</html>