私はプログラミングが初めてで、援助が必要です。私も持っているHTMLフォームを使用したPHPの値の割り当てと計算
<?php
include ('dbconnect.php');
// get values from the form
function getPosts(){
$posts = array();
$posts[0] = $_POST['bookingid'];
$posts[1] = $_POST['bookingname'];
$posts[2] = $_POST['lengthofstay'];
$posts[3] = $_POST['guests_description'];
$posts[4] = $_POST['startdate'];
$posts[5] = $_POST['enddate'];
$posts[6] = $_POST['other_information'];
return $posts;
}
if (isset($_POST['bookingdetails'])) {
$data = getPosts();
if (empty($bookingname)){
$errors[] = "Please enter the your booking name.";
}
if(empty($errors)){
foreach($errors as $error){
echo $error . "<br/>";
}
else{
$insert_Query = "insert into bookings
(Bookingid,Bookingname,Lengthofstay,Details_about_guests,
Booking_start_date,Booking_end_date,Other_relavant_information)
values ('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]',
'$data[5]','$data[6]')";
$result = mysqli_query($db, $insert_Query);
if ($result)
{
echo "<font color = 'green' . <p>Successfully Booked</p> </font>";
}
else{
echo "<p> Something went Wrong </p>" . mysqli_error ($db);
}
}
}
?>
:私はまた、次のようになります。同じページ上のPHPコードを持って
<form method = "post" action = "" >
<table cellspacing="15">
<tr>
<th>Bookingid </th>
<td><input type = "text" name = "bookingid"/> </td>
</tr>
<tr>
<th>Booking Name </th>
<td><input type = "text" name = "bookingname" /> </td>
</tr>
<tr>
<th> <label for = "Cabin Type">Cabin Type </label> </th>
td><select name = "Cabin Type" id = "Cabin Type">
<option select>Select a Cabin Type</option>
<option value = "Luxury Cabin">Luxury Cabin </option>
<option value = "Contemporary Cabin">Contemporary Cabin </option>
<option value = "Original Cabin">Original Cabin </option>
</select>
</td>
</tr>
<tr>
<th>Length of Stay </th>
<td><input type = "text" name = "lengthofstay" /> </td>
</tr>
<tr>
<th>Details About Guests </th>
<td><textarea cols = "30" rows = "5" type = "text" name="guests_description"
/> </textarea> </td>
</tr>
<tr>
<th>Booking Start Date </th>
<td><input type = "text" name = "startdate" /> </td>
</tr>
<tr>
<th>Booking End Date </th>
<td><input type = "text" name = "enddate" /> </td>
</tr>
<tr>
<th>Other Relavant Information </th>
<td><textarea cols = "30" rows = "5" type = "text" name="other_information"
/> </textarea> </td>
</tr>
<tr>
<th> </th>
<td> <input type = "submit" value = "Create Booking!" name =
"bookingdetails" /> </td>
</tr>
</table>
</form>
:私は、次のコードでaddbooking.phpというページにHTMLフォームを持っています私のデータベース内のテーブルのように見えたキャビンと呼ばれる:私はいくつかの支援がどのように私はCABIからの価格のそれぞれを割り当てないで必要なものを、今
n_Price列をフォーム上のドロップダウンメニューの各項目に入力し、「予約詳細」ボタンを押すと、「1200」の選択された値/オプションに「Stay of Stay」フィールドに入力された値例えば 'php'を使った '4'。オプションの値は、キャビンのIDになるよう
は ''
''の代わりに ''を使用できますか?あなたは正確な価値を得ることができます。値は「価格」として表すことができるので、そこに値を入れることができます。 – Jonjie
@ハッシュ価格をフォームに入れることは非常に悪い考えです。ユーザーは開発者ツールでフォームを変更して価格を変更することができます。 – Barmar