如何通过匹配url中的变量将值插入数据库


How can I insert a value to DB by matching variable in url?

我有一个表单中的两个表单。我可以成功地将数据存储到数据库中。当提交的表单用户将指向第二个表单时。我将url中的变量$uniqueid从第一个表单传递到第二个窗体。但是,当我尝试将第二个表格的数据存储到与同一用户相关的数据库中时,它没有存储。

我想存储第二页中用户的手机号码。数据库列也是手机号码。

This is my code
<?php
include_once 'dbconnect.php';
$a = $_GET['uniquekey'];

if(isset($_POST['btn-signup']))
{
    $mobilenumber = $_POST['mobilenumber'];

    $xxx = mysql_query("SELECT * FROM who WHERE uniquekey = '$a'")or die(mysql_error());
    $yyy = mysql_fetch_row($xxx);
    if(mysql_num_rows($xxx) > 0) {
        $aaa = mysql_query("INSERT INTO who(mobilenumber) VALUES('$mobilenumber')");
    }
    else{
        echo 'wrong';
    }
}
?>
$xxx = mysql_query("SELECT * FROM who WHERE uniquekey = '$a'")or die(mysql_error());
    $yyy = mysql_fetch_row($xxx);
    if(mysql_num_rows($xxx) > 0) {
$aaa = mysql_query("UPDATE who setmobilenumber='$mobilenumber' where uniquekey = '$a' ");
    }
    else{
        echo 'wrong';
    }

在这里,您可以使用更新查询来更新用户的手机号码。

include_once 'dbconnect.php';
$a = $_GET['uniquekey'];
if(isset($_POST['btn-signup']))
{
$mobilenumber = $_POST['mobilenumber'];
$xxx = mysql_query("SELECT * FROM who WHERE uniquekey = '$a'")or die(mysql_error());
$yyy = mysql_fetch_row($xxx);
if($yy>0)
{
$update="update who set mobilenumber=$mobilenumber where uniquekey='$a'"; 
$query=mysql_query($update);
}
else
    {
    echo "wrong";
    }
}