我一直在努力解决同样的问题。当它只是提交按钮,一切都很好。但是,当我将其更改为图像(替换type = submit with type = image)或将图像设置为背景图像时,它只是不起作用。感谢任何帮助,谢谢。
<form method='post' action='contact-form-proc.php' name='contactform' id='contactform'>
<p>
<label for='fullname'>Your Name:</label><br/>
<input type='text' name='fullname' />
</p>
<p>
<label for='email' >Email Address:</label><br/>
<input type='text' name='email' />
</p>
<input type='submit' name='submit' value='' id='submit' />
</form>
<style>
label{
font-family:Arial, Helvetica;
font-size:0.8em;
}
#submit{
background-image:url('submitP.gif');
height:2.5em;width:9em;
border:0;
display:block;
}
</style>
<?php
if(empty($_POST['submit']))
{
echo "Form is not submitted!";
exit;
}
if(empty($_POST["fullname"]) ||
empty($_POST["email"]))
{
echo "Please fill the form";
exit;
}
$name = $_POST["fullname"];
$email = $_POST["email"];
mail( 'info@xyz.com' , 'New form submission' ,
"New form submission: Name: $name, Email:$email" );
header('Location: thank-you.html');
?>
答案 0 :(得分:0)
试试这个
<button type="submit"><img src="submitP.gif" id="submit"></button>
答案 1 :(得分:0)
我刚刚在表单中添加了这个:
这样我就可以在PHP中收到$ _POST ['submit']。
感谢Melkis。