colombo colombo - 7 months ago 15
PHP Question

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

I have a two forms from one form. I can sucessfully store the data to database.when that form submitted user will directed to the second form. I am passing variable $uniqueid in the url from first form to second form. But, when I tried stored the data of the second form into the database that relevant to the same user its not stored.

I want to store mobile number of the user from second page.databse column also mobile number.

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';
}

}

?>

Answer
$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';
    }

Here you can use update query for update user mobile number.