测试代码时不显示PHP代码

时间:2022-04-09 18:21:56

I am attempting to try and save user input in a form based upon important pieces of information like Name, Prayer Request, Phone Number, etc. The idea is a person navigates to the web page and then fills out the information and then clicks a submit button which then saves the data to the database. Whenever I attempt to test the page literally nothing pulls up. I have looked over my code numerous times and cannot find the problem. I had a rough template to base my PHP off of. Within it there is a "Show all" button which does not need to be on the page at all. Any suggestions would be greatly appreciated. My code (including the "show all" button code) can be found below:

我试图根据名称,祷告请求,电话号码等重要信息在表单中保存用户输入。想法是一个人导航到网页,然后填写信息,然后单击提交按钮,然后将数据保存到数据库。每当我尝试测试页面时,字面上都没有任何结果。我已多次查看我的代码,无法找到问题。我有一个粗略的模板来基于我的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); 
} 
?>

1 个解决方案

#1


0  

Try with this for connection

尝试使用此连接

$conn = mysql_connect('XXXXXX','XXXX','XXXXXX')             or 
die("Could not connect: " . mysql_error()); 
//select the database 
$db = mysql_select_db("prayer",$conn);

#1


0  

Try with this for connection

尝试使用此连接

$conn = mysql_connect('XXXXXX','XXXX','XXXXXX')             or 
die("Could not connect: " . mysql_error()); 
//select the database 
$db = mysql_select_db("prayer",$conn);