我试图根据名称,祷告请求,电话号码等重要信息以表格保存用户输入。想法是一个人导航到网页,然后填写信息,然后单击提交按钮,然后将数据保存到数据库。每当我尝试测试页面时,字面上都没有任何结果。我已多次查看我的代码,无法找到问题。我有一个粗略的模板来基于我的PHP。在其中有一个“全部显示”按钮,根本不需要在页面上。任何建议将不胜感激。我的代码(包括“全部显示”按钮代码)可以在下面找到:
<?php
$Req_F_Name = $_POST["Req_F_Name"];
$Reg_L_Name = $_POST["Reg_L_Name"];
$Reg_Phone = $_POST["Reg_Phone"];
$Reg_Email= $_POST["Reg_Email"];
$Reg_Request = $_POST["Reg_Request"];
$Reg_Address_1= $_POST["Reg_Address_1"];
if ($Submit) {
$conn = mysql_connect('XXXXXX','XXXX','XXXXXX','prayer') or
die("Could not connect: " . mysql_error());
//select the database
$db = mysql_select_db("prayer");
$query = "INSERT INTO Request VALUES ('".$Req_F_Name."','".$Reg_L_Name."','".$Reg_Phone."','".$Reg_Email."','".$Reg_Request."',' ".$Reg_Address_1."')"or die(mysql_error());
echo "Your Query was successfully stored in the database :)";
mysql_close($conn);
}
if ($Show_All_Records) {
//establish connection to mysql
$conn = mysql_connect('XXXXXX','XXXXXX','XXXXXX','prayer')
or
die("Could not connect: " . mysql_error());
echo "Connected to MySql".'<br>'.'<br>';
//select the database
$db = mysql_select_db("prayer");
$result = mysql_query("SELECT * FROM 'Request'",$conn);
//display the results
echo 'First Name:', $Req_F_Name ,'<br>'
. 'Last Name:', $Reg_L_Name ,'<br>'
. 'Phone Number:', $Reg_Phone ,'<br>'
. 'Email:', $Reg_Email ,'<br>'
. 'Prayer Request:', $Reg_Request ,'<br>'
. 'Address:', $Reg_Address_1 ,'<br>'.'<br>';
//grabbing all data from the table
echo 'Your Query was succesfully stored in the database :)';
while ($myrow = mysql_fetch_array($result)) {
echo ''.$myrow["Req_F_Name"].' <br> '.$myrow["Reg_L_Name"].' <br>'.$myrow["Reg_Phone"].' <br> '.$myrow["Reg_Email"].' <br> '.$myrow["Reg_Request"].' <br> '.$myrow["Reg_Address_1"].' <br>';
}
mysql_close($conn);
}
?>
答案 0 :(得分:0)
尝试连接
$conn = mysql_connect('XXXXXX','XXXX','XXXXXX') or
die("Could not connect: " . mysql_error());
//select the database
$db = mysql_select_db("prayer",$conn);