html表单的php脚本不工作

y53ybaqx  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(316)

大家好,我有这两个脚本来填充我的电脑上的一个数据库表,一个html表单。html代码工作的完美,但php它只是不工作,我已经指定了一切,但它就是不工作,当我给点击提交浏览器只是弹出一个下载选项,但没有别的。。。

<html>
<head>
<tittle>
<h1 > <b> FORMAT FOR TECHNICAL ISSUES
<link rel="stylesheet" href="/var/www/html/proyecto/css/styles.css">
 </b> </h1>
</tittle>
<hr> </hr>
</head>
<body>
<div>
 <img src="logo.png" width=100%   /img>
<hr> </hr>
<form method="POST" action="">   
<input type="text" placeholder="NOMBRE" name="Nombre"  maxlenght="30" size="20px" id="nombre"  > 
<input type="text" name="Extension"  placeholder=EXTENSION  maxlength="5" id="extension">
<br>
<hr> </hr>
<br>
<br>
<h2> CAMPAIGN /CAMPAÑA </h2>
<br>
<label for="Campaign"> Select your campaign:</label>
<select name="Campaign" id="campaign"  >Campaign
    <option value="Procall">Procall</option>
    <option value="Tigo">Tigo</option>
    <option value="Spanish">Spanish</option>
</select>
<hr> </hr>
<h2> KIND OF FAILURE </h2>
<label for="Tipo de incidente">Select the type of incident:</label>
<select id="incident"  name="incidente"  placeholder="Tipo de incidente">incident
    <option value="Slow Computer">Slow Computer</option>    
    <option value="Headset fail"> Headset Fail </option>
    <option value="Zoiper Issue">Zoiper Issue </option>
       <option value="Crm Issue">Crm Issue </option>
       <option value="Spark Issue">Spark Issue </option>
       <option value="Vc Dialer Issue">VC Dialer Issue </option>
       <option value="Network Issue">Network Issue </option>
</select>
<input type"text" id="description"  name="Description" placeholder=DESCRIPTION style="width:300px;height:100px">
<br></br>
<h2>FAILURE DATE </h2>
<label for="failure date"> Enter the day and hour when failure occurred :</label>
<input name="failure_date"   type="date-time-local" placeholder="yyyy/mm/dd/hh/mm"  id="failure date" min="2018-05-01T08:30" max="2018-12-30T22:30"  >
<br>
<hr></hr>
<label for="did you lose a call?" id="lost_call" >Did you lose any call?:</label>
<br>
 <input type="radio" name="lost call" value="yes " id="lost_call" > Yes , i lost a call.
<br> 
<input type="radio" name="lost_call" value="no" id="lost_call" >No i have not lost any call
<br
<br>
<label id="lost docmuent"  for="did you lose any document?"> Did you lose any document or information?:</label>
<br>
<input type="radio" name="document" value="yes"> Yes i lost one or more documents
<br>
<input type="radio" name="document" value="no"> No have not lost any document. 
<br>
<br>
<label for="did you have to log out?" id="logout" > Did you have to logout?:</label>
<br>
<input type="radio" name="logout" value="yes">Yes i had to logout
<br>
<input type="radio" name="logout" value="no">no  i didn't have  to logout
<br>
<br>
<br>
<br>
<input type="submit">
 </form>
 </div>
 </body>
 </html>

下面是操作和连接到sql数据库的php脚本

<?php
 $con = mysql_connect("localhost","root","m0l0t0v" );
 if (!$con) {
      die('Could not connect: ' . mysql_error());
}
mysql_select_db("it", $con);
$sql="INSERT INTO tec-issues (Nombre,Extension ,Campaign ,incidente,Description,failure_date,lost_call,document,logout )
VALUES
('$_POST[Nombre]', '$_POST[Extension]', '$_POST[Campaign]', '$_POST[incidente]', '$_POST[Description]', '$_POST[failure_date]', '$_POST[lost_call]', '$_POST[document]', '$_POST[logout]' )";
if (!mysql_query($sql,$con)) {
      die('Error: ' . mysql_error());
} 
echo "1 record added";
mysql_close($con)
?>

请帮助我一切都是正确的,但它只是不工作

kx5bkwkv

kx5bkwkv1#

检查mysql\u select\u db的语法应该是mysql\u select\u db($con,“dbname”),请使用mysqli前缀而不是mysql,因为这样更安全。
我建议对从post中获得的每个数据使用msqli\u escape\u字符串,或者对sql注入进行保护

相关问题