0
我有問題,當我通過HTML運行PHP代碼,當我提交表單它顯示文件的頁面沒有找到或刪除,當我跑我分別在本地主機上,將數據成功提交到數據庫如何在PHP鏈接HTML文件時提交數據?
<div class="top-nav">
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header navbar-left">
<h1><a class="navbar-brand wow bounceIn animated" data-wow-delay=".5s" style="visibility: visible; -webkit-animation-delay: .5s;" href="index.html">PROJECT</a></h1>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-left">
<li class="hvr-bounce-to-bottom "><a href="index.html">Home</a></li>
<li class="hvr-bounce-to-bottom"><a href="Currency Converter.html">Currency Converter</a></li>
<li class="hvr-bounce-to-bottom active"><a href="Vehicles.html">Vehicles</a></li>
<li class="hvr-bounce-to-bottom"><a href="php.php">Car Registeration</a></li>
</ul>
<div class="clearfix"> </div>
</div>
</div>
</nav>
</div>
SQL代碼的HTML表單
<!DOCTYPE html>
<html>
<head>
<title>Form</title>
<link href="css/form.css" type="text/css" rel="stylesheet" media="all">
</head>
<body>
<div class="container">
<form id="contact" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<h3>Vehicle Registration Form</h3>
<fieldset>
<input name="firstname" placeholder="Enter Your First Name here" type="text" tabindex="1" required autofocus>
</fieldset>
<fieldset>
<input name="lastname" placeholder="Enter Your Last Name here" type="text" tabindex="2" required>
</fieldset>
<fieldset>
<input name="salary" placeholder="Enter Your Salary here" type="text" tabindex="3" required>
</fieldset>
<fieldset>
<input name="mobile" placeholder="Enter Your Mobile No. here" type="text" tabindex="4" required>
</fieldset>
<fieldset>
<input name="carbrand" placeholder="Enter Your Car Brand here" type="text" tabindex="5" required>
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit">Submit</button>
</fieldset>
</form>
</div>
<?php
if($_SERVER["REQUEST_METHOD"]=="POST"){
$firstname=$_POST["firstname"];
$lastname=$_POST["lastname"];
$salary=$_POST["salary"];
$mobile=$_POST["mobile"];
$carbrand=$_POST["carbrand"];
$db="yasir";
$user="root";
$pass="";
$server="localhost";
$conn=mysqli_connect($server,$user,$pass,$db) or die();
if($conn){
$query="INSERT into project VALUES(null,'".$firstname."','".$lastname."',".$salary.",".$mobile.",'".$carbrand."', null, null)";
$result = mysqli_query($conn, $query);
mysqli_close($conn);
echo 'connected';
}
}
?>
而且我希望頁面後的onclick提交被重定向到家裏。
所以我應該怎麼辦 – hasni
我應該怎麼添加和刪除來完成這個plzzz告訴我 – hasni
沒有親愛的其實我跑我的整個項目在當地的不住我運行這個地方我的前端和後端的工作文件夾保存的htdocs – hasni