好的,所以我的表格不起作用。没有值从表单传递到php。我需要javascript吗?我知道我的表单正在与php通信,因为当我填写字段时,我得到一行空白的字段。如果我再试一次,什么都不会进去。如果我删除空白行,再次尝试再提交另一行空白字段。
我的HTML格式:
<!-- Contact Us -->
<div data-role="page" id="contact_us" data-theme="c" data-title="Contact Us">
<div data-role="header">
<h1>Contact Us</h1>
<a data-rel="back" data-direction="reverse" href="#home">Back</a>
</div>
<div data-role="content">
<div class="contact-thankyou" style="display: none;">
Thank you. Your message has been sent. We will get back to you as soon as we can.
</div>
<p>Please Contact us if you wish to report any complaint or would like more information.</p>
<p>Street Address<br/>City, Country</p>
<p><a href="tel:5555555555">(555) 555-5555</a></p>
<div class="contact-form">
<br><p>Why not sign up for our exclusive newsletter???</p></br>
<p class="mandatory">* indicates Manadatory Field</p>
<div data-role="fieldcontain" class="text-field">
<label for="firstname">First Name*:</label>
<input type="text" name="firstname" value="" placeholder="" class="required" id="firstname" />
</div>
<div data-role="fieldcontain" class="text-field">
<label for="surname">Last Name*:</label>
<input type="text" name="surname" value="" placeholder="" class="required" id="surname" />
</div>
<div data-role="fieldcontain" class="text-field">
<label for="email">Email Address*:</label>
<input type="email" name="email" value="" placeholder="" class="required" id="email" />
</div>
<div data-role="fieldcontain" class="text-field">
<label for="mobilephone">Mobile Number:</label>
<input type="number" name="mobilephone" value="" placeholder="" id="mobilephone" />
</div>
<div data-role="fieldcontain">
<label for="state">Country*:</label>
<select name="country" class="required" id="country">
<option value="" data-placeholder="true">Please select your country</option>
<!-- country options -->
</select>
</div>
<div data-role="fieldcontain">
<label for="message">Any<br>Thing<br>To say?:</br></label>
<textarea name="message" id="message" placeholder=""></textarea>
</div>
<div class="send"><a href="signup.php" data-role="button" data-theme="a" data-iconpos="right" id="send-info">Submit</a></div>
</div><!-- //.contact-form -->
我的php插入表单:
<html>
<head>
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1">
<link rel="stylesheet" href="includes/themes/manutd.css" />
<link rel="stylesheet" href="includes/themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile.structure-1.4.2.min.css" />
<link rel="stylesheet" href="includes/maincss.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script src="includes/manunited.js"></script>
</head>
<body>
</body>
</html>
<?php
$con = mysql_connect("localhost","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("manunited", $con);
$sql="INSERT INTO People (firstname, surname, email, mobilephone, country, message)
VALUES ('$_POST[firstname]','$_POST[surname]','$_POST[email]','$_POST[mobilephone]','$_POST[country]','$_POST[message]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Thank you for signing up!";
//12. Link back to the main page
echo "<a href='index.html'> </a>";
mysql_close($con);
?>
任何帮助都会非常感激。此外,无需担心mysql折旧或注入,它不会被托管或上线。谢谢!
答案 0 :(得分:0)
您需要使用表单发布:
<form action="signup.php" method="post"> The html form you posted here </form>
添加提交按钮,而不是signup.php的链接:
<input type="submit" value="Signup"/>