我是新來的PHP和數據庫,這是我的PHP代碼:如何使用URL中的參數將數據插入到mySql數據庫中?
<?php
$email = $_POST['Email'];
$tc = $_POST['TotalCash'];
$tr = $_POST['TotalReferalls'];
// Connects to your Database
mysql_connect("205.178.146.92", "user", "pass") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
mysql_query("INSERT INTO UserInformation(Email, TotalCash, TotalReferalls) VALUES('$email', '$tc', '$tr')");
Print "Your table has been populated";
?>
這個工程時,我改變$email
和所有的變量設定值,如$email = '[email protected]'
,$tc = 3
,$tr = 4
,但是當我嘗試通過調用URL來設置它(mysite.com/myphp.php?$email='[email protected]'& $ tc = 4 & $ tr = 2)它不起作用,請顯示一種工作方式來設置來自url的參數。
在此先感謝!
非常感謝! – Paluter 2011-06-15 02:32:39