过去几天,当我添加密码时,我的联盟会员注册表格无法正常工作。我正在尝试使用password_hash()使其安全,因为我正在经历并确保一切尽可能安全和紧密。代码如下。表格不断回击消息"发生错误"当SQL查询不起作用时会发生这种情况(错误)。
<?php
/*
*
* Copyright 2017 by Jarrod Estepp
* This script is private software and is illegal to
* use without consent from Jarrod Estepp - hello@jarrodestepp.me
*
* register_process.php
*/
include('../includes/settings.php');
include('../includes/mysql.php');
//Grab Login Info
$company = $_POST['company'];
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$password = $_POST['password'];
$password_hash = password_hash($password, PASSWORD_DEFAULT);
$skype = $_POST['skype'];
$aol = $_POST['aol'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$payment_method = $_POST['payment_method'];
$payment_details = $_POST['payment_details'];
$traffic_detail = $_POST['traffic_detail'];
$security_pin = $_POST['security_pin'];
$ip = getIP();
//check if email is already in use
$checkUser = $conn->query("SELECT `email` FROM `affiliates` WHERE `email` = '{$email}'");
$check = $checkUser->num_rows;
if($check > 0) {
header("location: {$website_domain}/admin/settings_admins_add?s=1");
die();
}
$sql = $conn->query("INSERT INTO affiliates (status, company, first_name, last_name, phone, email, password, skype, aol, address, city, state, zip, country, payment_method, payment_details, traffic_detail, security_pin)
VALUES ('1', '$company', '$first_name', '$last_name', '$phone', '$email', '$password_hash', $skype', '$aol', '$address', '$city', '$state', '$zip', '$country', '$payment_method', '$payment_details', '$traffic_detail', '$security_pin')");
if(!$sql) {
header("location: {$website_domain}/affiliate/register?s=2");
die();
} else {
header("location: {$website_domain}/affiliate/register?s=3");
die();
}
?>
接下来我已经包含了实际的表格,如果有一个问题,我真的认为它在registration_process.php页面,但正如所说我没有运气得到它修复。我已经查看了这个以及更多的网站寻求帮助,但没有任何内容。
<?php
/*
*
* Copyright 2017 by Jarrod Estepp
* This script is private software and is illegal to
* use without consent from Jarrod Estepp - hello@jarrodestepp.me
*
* register.php
*/
include('../includes/settings.php');
include('../includes/mysql.php');
@$status = $_REQUEST['s'];
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="assets/css/login.css">
<script src="assets/js/login.js"></script>
<title><?php echo $website_name; ?> - Affiliate Registration</title>
</head>
<div class="login-page">
<div class="form">
<center><h3>Affiliate Registration</h3></center>
<?php
if($status == 1) {
echo '<font color="red">Email is already connected to an account.</font>';
}
if($status == 2) {
echo '<font color="red">An error occurred.</font>';
}
if($status == 3) {
echo '<font color="green">Affiliate Account Successfully Created! Please allow up to 48 hours for your application to
be reviewed. One of our managers may reach out to you during this time!</font>';
}
?>
<form class="login-form" action="register_process" name="affiliate_login" method="post">
<input type="text" name="company" placeholder="Company"/>
<input type="text" name="firstname" placeholder="First Name" required>
<input type="text" name="lastname" placeholder="Last Name"required>
<input type="text" name="phone" placeholder="Phone" required>
<input type="text" name="email" placeholder="Email" required>
<input type="password" name="password" placeholder="Password" required>
<input type="text" name="skype" placeholder="skype"/>
<input type="text" name="aol" placeholder="AOL"/>
<input type="text" name="address" placeholder="Mailing Address" required>
<input type="text" name="city" placeholder="City" required>
<input type="text" name="state" placeholder="State" required>
<input type="text" name="zip" placeholder="Zip/Postal Code" required>
<label><b>Country:</b></label>
<select name="country" required>
<option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia, Plurinational State of</option>
<option value="BQ">Bonaire, Sint Eustatius and Saba</option>
<option value="BA">Bosnia and Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CD">Congo, the Democratic Republic of the</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Côte d'Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CW">Curaçao</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands (Malvinas)</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GG">Guernsey</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard Island and McDonald Islands</option>
<option value="VA">Holy See (Vatican City State)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran, Islamic Republic of</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IM">Isle of Man</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JE">Jersey</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">Korea, Democratic People's Republic of</option>
<option value="KR">Korea, Republic of</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People's Democratic Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macao</option>
<option value="MK">Macedonia, the former Yugoslav Republic of</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia, Federated States of</option>
<option value="MD">Moldova, Republic of</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="ME">Montenegro</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PS">Palestinian Territory, Occupied</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Réunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="BL">Saint Barthélemy</option>
<option value="SH">Saint Helena, Ascension and Tristan da Cunha</option>
<option value="KN">Saint Kitts and Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="MF">Saint Martin (French part)</option>
<option value="PM">Saint Pierre and Miquelon</option>
<option value="VC">Saint Vincent and the Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome and Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="RS">Serbia</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SX">Sint Maarten (Dutch part)</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia and the South Sandwich Islands</option>
<option value="SS">South Sudan</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard and Jan Mayen</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan, Province of China</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania, United Republic of</option>
<option value="TH">Thailand</option>
<option value="TL">Timor-Leste</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela, Bolivarian Republic of</option>
<option value="VN">Viet Nam</option>
<option value="VG">Virgin Islands, British</option>
<option value="VI">Virgin Islands, U.S.</option>
<option value="WF">Wallis and Futuna</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
</select><br><br>
<?php
$paymentType = $conn->query("SELECT * FROM payment_types");
echo "<label><b>Payment Method:</b></label> ";
echo "<select name='payment_method' required>";
while($row = mysqli_fetch_array($paymentType, MYSQL_ASSOC)) {
$id = $row['id'];
$name = $row['name'];
echo "<option value='{$id}'>{$name}</option>";
}
echo "</select>";
?> <br><br>
<label><b>Payment Details:</b></label>
<textarea cols="30" rows="6" name="payment_details" placeholder="Payment Details" required></textarea><br><br>
<label><b>Traffic Detail:</b></label>
<textarea cols="30" rows="6" name="traffic_detail" placeholder="Traffic Detail" required></textarea><br><br>
<input type="text" name="security_pin" placeholder="Account Security Pin" required>
<button type="submit">Register</button>
</form>
</div>
</div>
</html>
**不介意我的版权。这是我的第一个项目,到目前为止我已经学到了很多,但这是一个我没有在几小时内修复的问题。所有答案都赞赏!
答案 0 :(得分:0)
尝试此查询:
$sql = $conn->query("INSERT INTO affiliates (status, company, first_name, last_name, phone, email, password, skype, aol, address, city, state, zip, country, payment_method, payment_details, traffic_detail, security_pin) VALUES ('1', '$company', '$first_name', '$last_name', '$phone', '$email', '$password_hash', '$skype', '$aol', '$address', '$city', '$state', '$zip', '$country', '$payment_method', '$payment_details', '$traffic_detail', '$security_pin')");
在您的值$skype
之前缺少一个引号。您下次应该使用mysqli_error
。
编辑: 刚才看到,解决方案已经在评论中了。我太慢了。