I have a website that converts the input texts to QRcode. The problem is that I can only get access to the first input text. For example I have this code:
Page1.php
<form action="getForm.php" method="post">
<input type="text" id="text1id" name="Text1"> //I have access
<input type="number" id="text2id" name="text2"> <br><br> //I dont have access
<input type="submit" value="Submit" name="submit_y">
</form>
if(isset($_POST['submit_y']))
{
include('phpqrcode/qrlib.php');
$text=$_POST['Text1'];
//I tried to put here the POST of Text2
$folder="images/";
$file_name="qr.png";
$file_name=$folder.$file_name;
QRcode::png($text,$file_name);
echo"<img src='images/qr.png'>";
//To Display Code Without Storing
//QRcode::png($text);
}
Assign variables to each POST array, then use the one from both to form a third variable from the concatenated ones.
if(isset($_POST['submit_y']))
{
include('phpqrcode/qrlib.php');
$text1=$_POST['Text1'];
$text2=$_POST['text2'];
$text3 = $text1. "" . $text2; // concatenated from previous 2
$folder="images/";
$file_name="qr.png";
$file_name=$folder.$file_name;
QRcode::png($text3,$file_name); // used $text3 from the concatenated variables
echo"<img src='images/qr.png'>";
//To Display Code Without Storing
//QRcode::png($text);
}
However, it is best to also check if any of the inputs are empty.
Sidenote:
In this $text3 = $text1. "" . $text2;
you can add anything inside the ""
as a separator.
I.e.: using an underscore.
$text3 = $text1. "_" . $text2;
It could also be a space
$text3 = $text1. " " . $text2;