這是我的投票代碼 我在快樂的MysqlAJAX調用遠程文件
<form role="form" action="graduating_students_preview.php" method="post">
<h3 class="style"> Student Performa</h3>
<p>Department:</p>
<select name="depart" required class="depart form-control btn-primary" >
<option value="">Department </option>
<option value="computer science">Computer Science</option>
<option value="zoology">Zoology</option>
</select>
<p>Degree</p>
<select name="degree" class="degree form-control btn-primary" required >
<option value=""> Degree </option>
<option value="computer science">Computer Science</option>
<option value="chemistry">Chemistry</option>
<option value="BBA">BBA</option>
</select>
<p>Semester</p>
<select class="form-control btn-primary" name="semester" required>
<option value="">semester</option>
<option value="1st">FIRST (01)</option>
<option value="2nd">SECOND (02)</option>
<option value="3rd">THIRD (03)</option>
<option value="4th">FOURTH (04)</option>
<option value="05">FIFTH (05)</option>
<option value="06">SIX (06)</option>
<option value="07">SEVEN(07)</option>
<option value="08">EIGHT (08)</option>
</select></td>
<p>Study Year</p>
<select class="form-control btn-primary" name="study_year" required>
<option value="" style="font-size:8px;">Select_year </option>
<option value="2014" label="2014">2014</option>
<option value="2013" label="2013">2013</option>
<option value="2012" label="2012">2012</option>
<option value="2011" label="2011">2011</option>
<option value="2010" label="2010">2010</option>
</select>
<p>Faculty</p>
<select name="faculty" class="faculty form-control btn-primary" required>
<option value="">Faculty</option>
<option value="science">Science</option>
<option value="Arts geg">Arts</option>
</select><br/>
<div class="container">
<p style="font-weight:bold">1. The work in the Program is too Heavy and induces a lot of
pressure</p>
<div class="radio">
<label><input type= "radio" name = "q1" value="very satisfied">very satisfied</label>
</div>
<div class="radio">
<label><input type= "radio" name= "q1" value="satisfied">satisfied</label>
</div>
<div class="radio">
<label><input type= "radio" name="q1" value="uncertain">uncertain</label>
</div>
獲取數據,這是我的PHP代碼
$db_name="performa"; // your database name
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); //mysql connection
mysql_select_db("$db_name")or die("can not select DB"); //select your database
error_reporting(E_ALL^E_NOTICE);
$depart = $_POST['depart'];
$degree = $_POST['degree'];
$semester = $_POST['semester'];
$study_year = $_POST['study_year'];
$faculty = $_POST['faculty'];
$query = "INSERT INTO performa1 (depart,degree,semester,study_year,faculty) VALUES ('$depart', '$degree', '$semester', '$study_year', '$faculty')";
mysql_query($query) or die('Query "' . $query . '" failed: ' . mysql_error());
// name, email and address are fields of your fields; test your table. $name, $email and $address are values collected from the form
?>
這是在網站工作正常,但我想使用它在英特爾XDK和英特爾XDK不支持PHP/MySQL,但我們可以用AJAX使用jQuery調用PHP文件 我試圖做到這一點做,但我不知道怎麼做是正確 所以誰能告訴我在哪裏放置PHP文件以及如何使用AJAX進行操作[R不同的程序 我只是想將數據進入數據庫
感謝
** **危險:您正在使用[**的**過時的數據庫API(http://stackoverflow.com/q/12859942/19068),並應使用[現代更換(HTTP:// php.net/manual/en/mysqlinfo.api.choosing.php)。你也**易受[SQL注入攻擊](http://bobby-tables.com/)**,一個現代的API會使[防禦]變得更容易(http://stackoverflow.com/quessations/60174/best-way-to-prevent-sql-injection-in-php)自己從。 – Quentin 2014-12-04 07:13:50
我應該在這段代碼中添加什麼? PHP中的newbee – 2014-12-04 07:25:20
它應該替換您用來訪問數據庫的現有代碼。 – Quentin 2014-12-04 07:29:55