我有一个表单,我需要它首先使用URL为几个字段插入数据。我在下面附上了我的表格样本。我们将它使用PHP发布到mySQL数据库中。我不介意它是如何进入那里的。但我见过使用example.com/form.php?add_1=10 The Street的例子,这对我来说是最好的方式。
谢谢,
<form role="form" method="post" action="<?php $_SERVER['PHP_SELF'] ?>" name="epicform">
<input type="text" class="form-control" id="lastname" name="surname" required style="
height: 35px;
">
<input type="text" class="form-control" id="add_1" name="add1" placeholder="Address Line 1" required style="
height: 35px;
">
<input type="text" class="form-control" id="add_2" name="add2" placeholder="Address Line 2" required style="
height: 35px;
">
<input type="text" class="form-control" id="add_3" name="add3" placeholder="Address Line 3" required style="
height: 35px;
">
<input type="text" class="form-control" id="postcode" name="postcode" placeholder="Postcode" required style="
height: 35px;
">
<input type="text" class="form-control" id="phone_number" name="phoneNum" placeholder="Phone Number" required style="
height: 35px;
">
</form>
我已经在这里试过了一个javascript解决方案,但我似乎无法做任何事情。
答案 0 :(得分:1)
<form role="form" method="post" action="<?php $_SERVER['PHP_SELF'] ?>" name="epicform">
<input type="text" class="form-control" id="add_1" name="add1" value="<?php echo $_GET['add1']; ?>" placeholder="Address Line 1" required style="height: 35px;">
</form>
现在您的网址必须正常工作! http://example.com/form.php?add_1=10
答案 1 :(得分:0)
您需要的是:http://www.php.net/manual/en/reserved.variables.get.php
http://urlToYourScript.php?add1=Randomstreet
<input type="text" class="form-control" id="add_1" name="add1"
placeholder="<?php echo $_GET['add1']; ?>" required style="height: 35px;">