我已经将页面打包,并在提交中调用另一个页面。我在 url 中传递了 id 和 name
我的网址就像
http://localhost/sfrefer/sf-refer-ap.php?id=45&cust_name=testing
在 sf-refer-ap.php 中
我使用以下代码
$name= $_POST['name'];
$mobile= $_POST['mobile'];
$custname1= $_POST['cust_name'];
echo $custname1;
$sql = "INSERT INTO test1 (name,email,mobile) VALUES ('$cust_name','$email[$i]', '$mobile[$i]')";
空值正在进入数据库...... 如何在数据库中插入id和cust_name
最佳答案
您使用GET
方法来传递id
和cust_name
。因为您在网址 id=45&cust_name=testing
$id = $_GET['id'];
$name= $_GET['cust_name'];
在尝试使用索引 cust_name
之前,您应该检查它是否确实存在于 $_GET
数组中。
if(isset($_GET['cust_name'])){ $name = $_GET['cust_name']; }
关于php - php中如何获取url值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40018738/