我在PHP的新手,但我创建使用HTML这种形式,我想将其存储在我的SQL数据库中,我已经无处不在网上查,但我可以'找不到如何存储包含用户国家HTML表单,如果有人可以帮我创建安全的PHP源代码,我将非常高兴并告诉我如何为此创建colume表,谢谢提前] [1]
[1]:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/fontawesome/css/font-awesome.css" >
<link rel="stylesheet" type="text/css" href="css/signup.css">
<script src="bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col col-md-2"></div>
<div class="col col-md-7">
<form id="frm" method="post">
<img src="img/mm.png">
<h1>Goldcoin WHITELISTING FORM</h1>
<br>
<label>First name</label>
<input type="" name="" class="form-control" placeholder="First name"><br>
<label>Last name</label>
<input type="" name="" class="form-control" placeholder="Last name"><br>
<label>Date of birth</label>
<input type="date" name="" class="form-control"><br>
<label>Phone Number</label>
<input type="tel" name="" placeholder="Phone Number" class="form-control"><br>
<label>Email Address</label>
<input type="email" name="" placeholder="Email" class="form-control"><br>
<label>Address</label>
<input type="text" name="" placeholder="Address1" id="Address1" class="form-control" ><br>
<input type="text" name="" placeholder="Address1" class="form-control" id="Address2"><br>
<input type="text" name="" placeholder="City" class="form-control" id="City"><br>
<input type="text" name="" placeholder="State/Province" class="form-control" id="City"><br>
<input type="text" name="" placeholder="Postal/Zip" class="form-control" id="City"><br>
<select class="form-control">
<option value="">Country</option>
<option value="Afghanistan">
Afghanistan
</option>
<option value="Albania">
Albania
</option>
<option value="Algeria">
Algeria
</option>
<option value="American Samoa">
American Samoa
</option>
<option value="Andorra">
Andorra
</option>
<option value="Angola">
Angola
</option>
<option value="Anguilla">
Anguilla
</option>
<option value="Antarctica" >
Antarctica
</option>
<option value="Antigua and Barbuda" >
Antigua and Barbuda
</option>
<option value="Argentina">
Argentina
</option>
<option value="Armenia">
Armenia
</option>
<option value="Aruba">
Aruba
</option>
<option value="Australia">
Australia
</option>
<option value="Austria">
Austria
</option>
<option value="Azerbaijan">
Azerbaijan
</option>
<option value="Bahamas">
Bahamas
</option>
<option value="Bahrain">
Bahrain
</option>
<option value="Bangladesh">
Bangladesh
</option>
<option value="Barbados">
Barbados
</option>
<option value="Belarus">
Belarus
</option>
<option value="Belgium">
Belgium
</option>
<option value="Belize">
Belize
</option>
<option value="Benin">
Benin
</option>
<option value="Bermuda">
Bermuda
</option>
<option value="Bhutan">
Bhutan
</option>
<option value="Bolivia">
Bolivia
</option>
<option value="Bosnia and Herzegovina">
Bosnia and Herzegovina
</option>
<option value="Botswana">
Botswana
</option>
<option value="Brazil">
Brazil
</option>
<option value="Brunei Darussalam">
Brunei Darussalam
</option>
<option value="Bulgaria">
Bulgaria
</option>
<option value="Burkina Faso">
Burkina Faso
</option>
<option value="Burundi">
Burundi
</option>
<option value="Cambodia">
Cambodia
</option>
<option value="Cameroon">
Cameroon
</option>
<option value="Canada">
Canada
</option>
<option value="Cape Verde">
Cape Verde
</option>
<option value="Cayman Islands">
Cayman Islands
</option>
<option value="Central African Republic">
Central African Republic
</option>
<option value="Chad">
Chad
</option>
<option value="Chile">
Chile
</option>
<option value="China">
China
</option>
<option value="Christmas Island">
Christmas Island
</option>
<option value="Cocos (Keeling) Islands">
Cocos (Keeling) Islands
</option>
<option value="Colombia">
Colombia
</option>
<option value="Comoros">
Comoros
</option>
<option value="Congo, Republic of(Brazzaville)">
Congo, Republic of(Brazzaville)
</option>
<option value="Cook Islands">
Cook Islands
</option>
<option value="Costa Rica">
Costa Rica
</option>
<option value="Croatia">
Croatia
</option>
<option value="Cuba">
Cuba
</option>
<option value="Cyprus">
Cyprus
</option>
<option value="Czech Republic">
Czech Republic
</option>
<option value="Democratic Republic of the Congo (Kinshasa)">
Democratic Republic of the Congo (Kinshasa)
</option>
<option value="Denmark">
Denmark
</option>
<option value="Djibouti">
Djibouti
</option>
<option value="Dominica">
Dominica
</option>
<option value="Dominican Republic">
Dominican Republic
</option>
<option value="East Timor (Timor-Leste)">
East Timor (Timor-Leste)
</option>
<option value="Ecuador">
Ecuador
</option>
<option value="Egypt">
Egypt
</option>
<option value="El Salvador">
El Salvador
</option>
<option value="Equatorial Guinea">
Equatorial Guinea
</option>
<option value="Eritrea">
Eritrea
</option>
<option value="Estonia">
Estonia
</option>
<option value="Ethiopia">
Ethiopia
</option>
<option value="Falkland Islands">
Falkland Islands
</option>
<option value="Faroe Islands">
Faroe Islands
</option>
<option value="Fiji">
Fiji
</option>
<option value="Finland">
Finland
</option>
<option value="France">
France
</option>
<option value="French Guiana">
French Guiana
</option>
<option value="French Polynesia">
French Polynesia
</option>
<option value="French Southern Territories">
French Southern Territories
</option>
<option value="Gabon">
Gabon
</option>
<option value="Gambia">
Gambia
</option>
<option value="Georgia">
Georgia
</option>
<option value="Germany">
Germany
</option>
<option value="Ghana" id="OPTION_81">
Ghana
</option>
<option value="Gibraltar">
Gibraltar
</option>
<option value="Great Britain">
Great Britain
</option>
<option value="Greece">
Greece
</option>
<option value="Greenland">
Greenland
</option>
<option value="Grenada">
Grenada
</option>
<option value="Guadeloupe" id="OPTION_87">
Guadeloupe
</option>
<option value="Guam" id="OPTION_88">
Guam
</option>
<option value="Guatemala" id="OPTION_89">
Guatemala
</option>
<option value="Guinea" id="OPTION_90">
Guinea
</option>
<option value="Guinea-Bissau" id="OPTION_91">
Guinea-Bissau
</option>
<option value="Guyana" id="OPTION_92">
Guyana
</option>
<option value="Haiti" id="OPTION_93">
Haiti
</option>
<option value="Holy See" id="OPTION_94">
Holy See
</option>
<option value="Honduras" id="OPTION_95">
Honduras
</option>
<option value="Hong Kong" id="OPTION_96">
Hong Kong
</option>
<option value="Hungary" id="OPTION_97">
Hungary
</option>
<option value="Iceland" id="OPTION_98">
Iceland
</option>
<option value="India" id="OPTION_99">
India
</option>
<option value="Indonesia" id="OPTION_100">
Indonesia
</option>
<option value="Iran (Islamic Republic of)" id="OPTION_101">
Iran (Islamic Republic of)
</option>
<option value="Iraq" id="OPTION_102">
Iraq
</option>
<option value="Ireland" id="OPTION_103">
Ireland
</option>
<option value="Israel" id="OPTION_104">
Israel
</option>
<option value="Italy" id="OPTION_105">
Italy
</option>
<option value="Ivory Coast" id="OPTION_106">
Ivory Coast
</option>
<option value="Jamaica" id="OPTION_107">
Jamaica
</option>
<option value="Japan" id="OPTION_108">
Japan
</option>
<option value="Jordan" id="OPTION_109">
Jordan
</option>
<option value="Kazakhstan" id="OPTION_110">
Kazakhstan
</option>
<option value="Kenya" id="OPTION_111">
Kenya
</option>
<option value="Kiribati" id="OPTION_112">
Kiribati
</option>
<option value="Korea, Democratic People's Rep. (North Korea)" id="OPTION_113">
Korea, Democratic People's Rep. (North Korea)
</option>
<option value="Korea, Republic of (South Korea)" id="OPTION_114">
Korea, Republic of (South Korea)
</option>
<option value="Kosovo" id="OPTION_115">
Kosovo
</option>
<option value="Kuwait" id="OPTION_116">
Kuwait
</option>
<option value="Kyrgyzstan" id="OPTION_117">
Kyrgyzstan
</option>
<option value="Lao, People's Democratic Republic" id="OPTION_118">
Lao, People's Democratic Republic
</option>
<option value="Latvia" id="OPTION_119">
Latvia
</option>
<option value="Lebanon" id="OPTION_120">
Lebanon
</option>
<option value="Lesotho" id="OPTION_121">
Lesotho
</option>
<option value="Liberia" id="OPTION_122">
Liberia
</option>
<option value="Libya" id="OPTION_123">
Libya
</option>
<option value="Liechtenstein" id="OPTION_124">
Liechtenstein
</option>
<option value="Lithuania" id="OPTION_125">
Lithuania
</option>
<option value="Luxembourg" id="OPTION_126">
Luxembourg
</option>
<option value="Macau" id="OPTION_127">
Macau
</option>
<option value="Macedonia, Rep. of" id="OPTION_128">
Macedonia, Rep. of
</option>
<option value="Madagascar" id="OPTION_129">
Madagascar
</option>
<option value="Malawi" id="OPTION_130">
Malawi
</option>
<option value="Malaysia" id="OPTION_131">
Malaysia
</option>
<option value="Maldives" id="OPTION_132">
Maldives
</option>
<option value="Mali" id="OPTION_133">
Mali
</option>
<option value="Malta" id="OPTION_134">
Malta
</option>
<option value="Marshall Islands" id="OPTION_135">
Marshall Islands
</option>
<option value="Martinique" id="OPTION_136">
Martinique
</option>
<option value="Mauritania" id="OPTION_137">
Mauritania
</option>
<option value="Mauritius" id="OPTION_138">
Mauritius
</option>
<option value="Mayotte" id="OPTION_139">
Mayotte
</option>
<option value="Mexico" id="OPTION_140">
Mexico
</option>
<option value="Micronesia, Federal States of" id="OPTION_141">
Micronesia, Federal States of
</option>
<option value="Moldova, Republic of" id="OPTION_142">
Moldova, Republic of
</option>
<option value="Monaco" id="OPTION_143">
Monaco
</option>
<option value="Mongolia" id="OPTION_144">
Mongolia
</option>
<option value="Montenegro" id="OPTION_145">
Montenegro
</option>
<option value="Montserrat" id="OPTION_146">
Montserrat
</option>
<option value="Morocco" id="OPTION_147">
Morocco
</option>
<option value="Mozambique" id="OPTION_148">
Mozambique
</option>
<option value="Myanmar, Burma" id="OPTION_149">
Myanmar, Burma
</option>
<option value="Namibia" id="OPTION_150">
Namibia
</option>
<option value="Nauru" id="OPTION_151">
Nauru
</option>
<option value="Nepal" id="OPTION_152">
Nepal
</option>
<option value="Netherlands" id="OPTION_153">
Netherlands
</option>
<option value="Netherlands Antilles" id="OPTION_154">
Netherlands Antilles
</option>
<option value="New Caledonia" id="OPTION_155">
New Caledonia
</option>
<option value="New Zealand" id="OPTION_156">
New Zealand
</option>
<option value="Nicaragua" id="OPTION_157">
Nicaragua
</option>
<option value="Niger" id="OPTION_158">
Niger
</option>
<option value="Nigeria" id="OPTION_159">
Nigeria
</option>
<option value="Niue" id="OPTION_160">
Niue
</option>
<option value="Northern Mariana Islands" id="OPTION_161">
Northern Mariana Islands
</option>
<option value="Norway" id="OPTION_162">
Norway
</option>
<option value="Oman" id="OPTION_163">
Oman
</option>
<option value="Pakistan" id="OPTION_164">
Pakistan
</option>
<option value="Palau" id="OPTION_165">
Palau
</option>
<option value="Palestinian territories" id="OPTION_166">
Palestinian territories
</option>
<option value="Panama" id="OPTION_167">
Panama
</option>
<option value="Papua New Guinea" id="OPTION_168">
Papua New Guinea
</option>
<option value="Paraguay" id="OPTION_169">
Paraguay
</option>
<option value="Peru" id="OPTION_170">
Peru
</option>
<option value="Philippines" id="OPTION_171">
Philippines
</option>
<option value="Pitcairn Island" id="OPTION_172">
Pitcairn Island
</option>
<option value="Poland" id="OPTION_173">
Poland
</option>
<option value="Portugal" id="OPTION_174">
Portugal
</option>
<option value="Puerto Rico" id="OPTION_175">
Puerto Rico
</option>
<option value="Qatar" id="OPTION_176">
Qatar
</option>
<option value="Reunion Island" id="OPTION_177">
Reunion Island
</option>
<option value="Romania" id="OPTION_178">
Romania
</option>
<option value="Russian Federation" id="OPTION_179">
Russian Federation
</option>
<option value="Rwanda" id="OPTION_180">
Rwanda
</option>
<option value="Saint Kitts and Nevis" id="OPTION_181">
Saint Kitts and Nevis
</option>
<option value="Saint Lucia" id="OPTION_182">
Saint Lucia
</option>
<option value="Saint Vincent and the Grenadines" id="OPTION_183">
Saint Vincent and the Grenadines
</option>
<option value="Samoa" id="OPTION_184">
Samoa
</option>
<option value="San Marino" id="OPTION_185">
San Marino
</option>
<option value="Sao Tome and Principe" id="OPTION_186">
Sao Tome and Principe
</option>
<option value="Saudi Arabia" id="OPTION_187">
Saudi Arabia
</option>
<option value="Senegal" id="OPTION_188">
Senegal
</option>
<option value="Serbia" id="OPTION_189">
Serbia
</option>
<option value="Seychelles" id="OPTION_190">
Seychelles
</option>
<option value="Sierra Leone" id="OPTION_191">
Sierra Leone
</option>
<option value="Singapore" id="OPTION_192">
Singapore
</option>
<option value="Slovakia (Slovak Republic)" id="OPTION_193">
Slovakia (Slovak Republic)
</option>
<option value="Slovenia" id="OPTION_194">
Slovenia
</option>
<option value="Solomon Islands" id="OPTION_195">
Solomon Islands
</option>
<option value="Somalia" id="OPTION_196">
Somalia
</option>
<option value="South Africa" id="OPTION_197">
South Africa
</option>
<option value="South Sudan" id="OPTION_198">
South Sudan
</option>
<option value="Spain" id="OPTION_199">
Spain
</option>
<option value="Sri Lanka" id="OPTION_200">
Sri Lanka
</option>
<option value="Sudan" id="OPTION_201">
Sudan
</option>
<option value="Suriname" id="OPTION_202">
Suriname
</option>
<option value="Swaziland" id="OPTION_203">
Swaziland
</option>
<option value="Sweden" id="OPTION_204">
Sweden
</option>
<option value="Switzerland" id="OPTION_205">
Switzerland
</option>
<option value="Syria, Syrian Arab Republic" id="OPTION_206">
Syria, Syrian Arab Republic
</option>
<option value="Taiwan (Republic of China)" id="OPTION_207">
Taiwan (Republic of China)
</option>
<option value="Tajikistan" id="OPTION_208">
Tajikistan
</option>
<option value="Tanzania; officially the United Republic of Tanzania" id="OPTION_209">
Tanzania; officially the United Republic of Tanzania
</option>
<option value="Thailand" id="OPTION_210">
Thailand
</option>
<option value="Tibet" id="OPTION_211">
Tibet
</option>
<option value="Timor-Leste (East Timor)" id="OPTION_212">
Timor-Leste (East Timor)
</option>
<option value="Togo" id="OPTION_213">
Togo
</option>
<option value="Tokelau" id="OPTION_214">
Tokelau
</option>
<option value="Tonga" id="OPTION_215">
Tonga
</option>
<option value="Trinidad and Tobago" id="OPTION_216">
Trinidad and Tobago
</option>
<option value="Tunisia" id="OPTION_217">
Tunisia
</option>
<option value="Turkey" id="OPTION_218">
Turkey
</option>
<option value="Turkmenistan" id="OPTION_219">
Turkmenistan
</option>
<option value="Turks and Caicos Islands" id="OPTION_220">
Turks and Caicos Islands
</option>
<option value="Tuvalu" id="OPTION_221">
Tuvalu
</option>
<option value="Uganda" id="OPTION_222">
Uganda
</option>
<option value="Ukraine" id="OPTION_223">
Ukraine
</option>
<option value="United Arab Emirates" id="OPTION_224">
United Arab Emirates
</option>
<option value="United Kingdom" id="OPTION_225">
United Kingdom
</option>
<option value="United States" id="OPTION_226">
United States
</option>
<option value="Uruguay" id="OPTION_227">
Uruguay
</option>
<option value="Uzbekistan" id="OPTION_228">
Uzbekistan
</option>
<option value="Vanuatu" id="OPTION_229">
Vanuatu
</option>
<option value="Vatican City State (Holy See)" id="OPTION_230">
Vatican City State (Holy See)
</option>
<option value="Venezuela">
Venezuela
</option>
<option value="Vietnam">
Vietnam
</option>
<option value="Virgin Islands (British)" id="OPTION_233">
Virgin Islands (British)
</option>
<option value="Virgin Islands (U.S.)" id="OPTION_234">
Virgin Islands (U.S.)
</option>
<option value="Wallis and Futuna Islands" id="OPTION_235">
Wallis and Futuna Islands
</option>
<option value="Western Sahara" id="OPTION_236">
Western Sahara
</option>
<option value="Yemen" id="OPTION_237">
Yemen
</option>
<option value="Zambia" id="OPTION_238">
Zambia
</option>
<option value="Zimbabwe" id="OPTION_239">
Zimbabwe
</option>
</select><br>
<label>Telegram username (Optional)</label>
<input type="text" name="" class="form-control" placeholder="Optional"><br>
<label>Any ERC20 Wallet</label>
<input type="text" name="" class="form-control" placeholder="Any ERC20 Wallet"><br>
<label>How Many Ethereum you want to Contribute ?</label>
<input type="text" name="" class="form-control" placeholder="Potiential Contribution (ETH)"><br><br><br>
<label>Gender</label>
<select class="form-control">
<option>Male</option>
<option>Female</option>
</select><br>
<h4>I am not a US Citizen</h4><br>
<label class="checkbox-inline">
<input type="radio" value="" name="group">Yes
</label>
<label class="checkbox-inline">
<input type="radio" value="" name="group">No
</label><br><br>
<button class="btn btn-danger" id="#bt2">Send Form</button>
</form>
</div>
<div class="col col-md-3"></div>
</div>
</div>
</body>
</html>
&#13;
答案 0 :(得分:1)
如果您按照以下步骤操作,则不应该出现问题。
每个输入都需要有一个名称
您需要在每个输入上添加一个名称,并在表单中选择如下:
<input type="" name="first" class="form-control" placeholder="First name">
您的表单需要操作
接下来,您需要更改表单,使其具有如下操作:
<form id="frm" method="post" action="saveForm.php">
之后,您将需要一个与操作同名的文件。在这种情况下,'saveform.php'与具有表单的页面相同的文件夹。如果您想要它在不同的文件夹中,您可以使用重新定位的URL更改它。
建立数据库连接并收集数据
接下来,您需要在php文件中建立数据库连接,并从$_POST[]
变量中获取所有数据,如下所示:
$firstName = $_POST['name'];
$lastName = $_POST['last'];
您在$_POST[]
变量中键入的名称应与您为每个输入元素名称指定的名称相匹配。
选择的值只是文字
要从select元素中获取国家/地区,请执行与上面完全相同的操作。
将国家/地区存储到数据库中时,没有什么特别之处。这只是文字。因此,您希望编写国家/地区的数据库中的任何列都应该只是纯文本。就那么简单。
更新代码请求
**连接到数据库示例:**
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
获取表单变量
$firstName = $_POST["name"];
$lastName = $_POST["last"];
插入数据库
$query = "INSERT INTO table_name (firstName,lastName,...) VALUES (".$firstName.",".$lastName.",...)";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);