我是 php 新手。我从互联网上找到了一个运行正常的脚本。但是当我将附件脚本添加到此文件时,它不再正常工作。
为了使其正常工作,我应该进行哪些更改?
否则,请进行更改以正常工作。
<html>
<?php
if($_GET['name']== '' || $_GET['email']=='' || $_GET['Message']=='' )
{
?>
<form action="check2.php" method="get" name="frmPhone">
<fieldset>
<legend style="color:#000">Contact </legend>
<table width="100%">
<tr>
<td width="29%">
<label for="name" <?php if(isset($_GET['Submit']) && $_GET['name']=='') echo "style='color:red'";?>>Name* </label> </td> <td width="71%">
<input id="name" name="name" type="text" style="width:50%" value=" <?php echo $_GET['name'];?>"/> </td> </tr> <tr> <td>
<label for=" email" <?php if(isset($_GET['Submit']) && $_GET['email']=='') echo "style='color:red'";?>>Email* </label> </td> <td>
<input id="email" name="email" type="text" style="width:50%" value=" <?php echo $_GET['email'];?>"/> </td> </tr>
</table>
</fieldset>
<fieldset>
<legend style="color:#000">Inquiry </legend>
<table width="100%">
<tr> <td width="41%" valign="top">
<label for="Message" <?php if(isset($_GET['Submit']) && $_GET['Message']=='') echo "style='color:red'";?>>Message* </label> </td> <td width="59%"> <textarea name="Message" rows="5" style="width:90%" id="Message"> <?php echo $_GET['Message'];?> </textarea> </td>
</tr>
<tr>
<td> </td>
<td align="right"> </td>
</table>
</fieldset>
</form>
<td>
<li id="li_8" >
<label class="description" <?php if(isset($_GET['Submit']) && $_GET['uploaded_file']=='') echo "style='color:red'"; ?> for="element_8">Upload your logo </label>
<div>
<input name="uploaded_file" class="element file" type="file"/>
</div> <p class="guidelines" id="guide_8"> <small>Upload your logo here. there is a max of 1 mb </small> </p>
</li> <li id="li_9" >
<label class="description" <?php if(isset($_GET['Submit']) && $_GET['uploaded_file']=='') echo "style='color:red'";?> for="element_9">Upload foto 1 </label>
<div>
<input name="uploaded_file" class="element file" type="file"/>
</div> <p class="guidelines" id="guide_9"> <small>Upload your logo here. there is a max of 1 mb </small> </p>
</li> <input name="Submit" type="submit" value="Submit" />
</form> </td>
</tr>
<?php
}
else
{
$to = 'yourmail@.com';
$subject = 'Customer Information';
$message = '
Name: '.$_GET['name'].'
Email Address: '.$_GET['email'].'
Message: '.$_GET['Message'];
$uploads_dir = '/uploads';
foreach ($_FILES["uploaded_file"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["uploaded_file"]["tmp_name"][$key];
$name = $_FILES["uploaded_file"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
$headers = 'From:'.$_GET['email'];
mail($to, $subject, $message, $headers, $uploads_dir);
$connection=mysql_connect("your host", "id", "pass") or die(mysql_error());
mysql_select_db("id") or die(mysql_error());
$query = mysql_query("INSERT INTO `feedback` ( `name` , `email` , `Message` , `uploaded_file` ) VALUES ('".$_GET['name']."', '".$_GET['email']."', '".$_GET['Message']."')");
echo "Thank you! ";
}
?>
</htm>