2015-10-20 117 views
0

好吧,我搜索了很多并没有帮助我。 我有这样的形式:从一个页面获取图像变量到另一个

<form action="update.php" id="Form2" method="POST" enctype="multipart/form-data" class="c"> 
    <div align="center"> 
    <?php echo "Updating information about Patient ".$row["name"]; ?> 
    <table class="imagetable" border="1" cellspacing="3" align="center"> 
     <th>Personal Informations</th> 
     <th>Test Results</th> 

     <tr><td>Name<br> 
      <input type="text" class="large-fld" name="name" placeholder="Patient Name" value="<?php echo $row['name'];?>"/></td> 
     <td>Remarcs:<br> 
      <textarea type="text" cols="40" rows="5" class="large-fld" name="remarcs" placeholder="Remarcs"><?php echo $row['remarcs'];?></textarea></td> 
     <tr><td>Address<br> 
      <input type="text" class="large-fld" name="address" placeholder="Address" value="<?php echo $row['address'];?>"/> 
     </td> 
     <td>Test<br> <textarea type="text" cols="40" rows="5" class="large-fld" name="test_res" placeholder="Test Result"><?php echo $row['test_res'];?></textarea></td></tr> 
     </td> 
     </tr> 
     <tr><td>Phone Number<br> 
      <input type="text" class="large-fld" name="phone_num" placeholder="Phone Number" value="<?php echo $row['phone_num'];?>"/> 
     </td> 
     <th>Files</th> 
     </tr> 
     <td>Scanned Echo Photo<br> 
     <input type="file" class="" name="echo_photo" id="echo_photo" placeholder="Add echo photo" value="<?php echo $row['echo_photo'];?>"/></td> 
     <td>Echo Files:<br> 
     <input type="file" name="fileToUpload" value="<?php echo $row['echo_files'];?>"/><br></td> 
     </tr></th></table> 
    <div class="row" align="center"> 
     <input type="submit" name="submit" id="btnUploadId" class="large-btn" value="Update" onClick="btnOnClickUpload()"> 
     <input type="hidden" id="courseIdHidden" value="<?php echo $idd; ?>" /></td></tr> 
     </table></div> 
</form> 

,我不能得到的图像和文件到下一个页面使用它们使用PHP来更新表:

$host=""; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name=""; // Table name 


$id=$_REQUEST['id']; 
if (isset ($_POST['name'])) { 
    $name = $_POST['name']; 
} 
if (isset ($_POST['remarcs'])) { 
    $remarcs = $_POST['remarcs']; 
} 
if (isset ($_POST['test_res'])) { 
    $test_res = $_POST['test_res']; 
} 
if (isset ($_POST['address'])) { 
    $address = $_POST['address']; 
} 

if (isset ($_POST['phone_num'])) { 
    $phone = $_POST['phone_num']; 
} 
echo $name; 
echo $remarcs; 
echo $test_res; 

echo $address; 
echo $phone; 

这些变量的回声是伟大的工作, 如何完成这项任务?请帮助

+0

访问他们加入你试过文件的代码。 –

+0

$ uploaddir =“../../user_content/photo/”; $ allowed_ext = array(“jpeg”,“jpg”,“gif”,“png”);如果(isset($ _ POST [“submit”])){ $ file_temp = $ _FILES ['file'] ['tmp_name']; $ info = getimagesize($ file_temp); } else { print“文件没有成功发送到服务器!”; 退出; } – droidnation

+0

在html中有很多杂散结束标签可能会导致您的问题。例如最后一个'' –

回答

0

您可以使用$ _SESSION变量来存储你的文件的信息,这样你会从不同的PHP文件

+0

我需要的是从html表单中获取值,包括文本和图像,并更新sql表格行。我在网上尝试了很多代码,但没有任何反应。那么有关代码的任何帮助? – droidnation

+0

还有什么帮助吗? – droidnation

+0

@droidnation你可以将你的文件保存在某个文件夹中,并且只保存它们在你的sql表中的路径,所以当你想要它们时,你可以检索路径和(如果它是一个图像)将它放到你的“src”属性中, – myxobek

相关问题