Query:
User input value(varchar) through sponsor id page (Simple form), then if id matched then move to registration page, for registration.
Verify Page:
<form action="verify_check.php" method="post" class="basic-grey">
<label>
<span>Sponser ID :</span>
<input type="text" name="token" value="" />
</label>
<label>
<span> </span>
<input type="submit" class="button" value="SignUp" name="submit"/>
</label>
</form>
Verify_check Page:
<?php
if (isset($_POST['submit']))
{
$token=$_POST['token'];
$conn=mysqli_connect("localhost","root","", "gold_99") ;
if(!$conn)
{
die("connection failed: ".mysqli_connect_error());
}
$sql = "SELECT * FROM personal_deatils WHERE userid = '$token'";
$row = mysql_fetch_array($sql)
if (mysqli_query($conn, $sql))
{
if($row =="$token"){
echo "Data Select Succefully";
}
else
echo "Wrong Connection";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
mysqli_close($conn);
?>
Database Architecture:
title (varchar), firstname (varchar), userid (varchar, primary), mobileno (varchar), email (varchar), country (varchar)
To use this solution, you have to store the generated token in database, say in user table or if you want you can save it in different table with respective to user id. For now, let's consider that whatever code you have stored in the session is stored in the user table too.
As you are asking a user to enter a verification code in the text box and you are sending the form to verify_check.php
. Now at verify_check
file you can get whatever code was entered by the user.
Now you can verify if the user's entered value is equal to sessions value as you have already done.
if (isset($_POST['token']) && isset($_SESSION['token']) && ($_POST['token'] == $_SESSION['token'])) {
Now you can query your database against this token and check whether you are getting any record for that user.
$con = mysql_connect("your_Hostname","your_username","your_password");
if (!$con) {
die("Not able to connect the database")
}
$db = mysql_select_db("your_databasename",$con);
if (!$db) {
die("Database not found");
}
$sql = "SELECT * FROM `your_table_name`
WHERE `token` = '" .$_POST['token']. "'";
$res = mysql_query($sql);
if ($res) {
$result = mysql_fetch_assoc($res);
if (isset($result['column_name_from_table_in_which_you_have_saved_user_id_at_registration_time'])) {
@header("Location:/mlm project/signup.php.");
}
} else {
echo "Error, Wrong Sponser ID " ;
}
}