PHP Echo Records Based Upon specified IDs - php

So i need a way to be able to echo $row['username'] and echo $row['password'] where the id is specified.
So example is i have 3 rows i need to get information from with id numbers 20, 56, 88.
Now i have made the query $query = "SELECT * FROM Card_File WHERE id = $id";
How do i echo this data (keeping in mind its not in a table and could be placed in random location on the webpage, and the forms the outputs will be going into will be different (eg, not got the same form field names.))
echo $row['username'] $id=20;
echo $row['password'] $id=20;
echo $row['username'] $id=56;
echo $row['password'] $id=56;
echo $row['username'] $id=88;
echo $row['password'] $id=88;
I have been looking arround and seen some very complicated examples but dont belive its that hard to echo a row by id. I may be wrong
Below is not a great example of what the ends result is but would give you an idea.
<!DOCTYPE html>
<html>
<head>
<?php
// Connect to the database
$link = mysqli_connect('localhost','root','pass','ACS_SHAREPOINT_ADDONS');
// Select table and arguments
$query = "SELECT * FROM Card_File WHERE id = $id";
$result = mysqli_query($link, $query);
?>
</head>
<body>
<?php foreach($row = mysqli_fetch_array($result)): ?>
<div class="loginForms">
<form target="_blank" action="https://www.website.com" method="post">
<input type="hidden" name="username" id="auth-form-login" value="<?php $id=20 echo $row['username']; ?>"/>
<input type="hidden" name="password" id="auth-form-pass" value="<?php $id=20 echo $row['password']; ?>"/>
<input type="hidden" name="redirDocument" value="user"/>
<input type="hidden" name="query" value=""/>
<input type="hidden" name="urlString" value="doc-rc-login;lng-ww-en;tpl-;ver-;"/>
<input type="submit" name="authSubmit" value="AVG Resellers Center" id="auth-form-submit"/>
</form>
</div>
<div class="loginForms">
<form target="_blank" action="https://www.website.com" method="post">
<input type="hidden" name="username" id="auth-form-login" value="<?php $id=56 echo $row['username']; ?>"/>
<input type="hidden" name="password" id="auth-form-pass" value="<?php $id=56 echo $row['password']; ?>"/>
<input type="hidden" name="redirDocument" value="user"/>
<input type="hidden" name="query" value=""/>
<input type="hidden" name="urlString" value="doc-rc-login;lng-ww-en;tpl-;ver-;"/>
<input type="submit" name="authSubmit" value="AVG Resellers Center" id="auth-form-submit"/>
</form>
</div>
<div class="loginForms">
<form target="_blank" action="https://www.website.com" method="post">
<input type="hidden" name="username" id="auth-form-login" value="<?php $id=88 echo $row['username']; ?>"/>
<input type="hidden" name="password" id="auth-form-pass" value="<?php $id=88 echo $row['password']; ?>"/>
<input type="hidden" name="redirDocument" value="user"/>
<input type="hidden" name="query" value=""/>
<input type="hidden" name="urlString" value="doc-rc-login;lng-ww-en;tpl-;ver-;"/>
<input type="submit" name="authSubmit" value="AVG Resellers Center" id="auth-form-submit"/>
</form>
</div>
<?php endforeach; ?>
</body>
</html>

I believe this is what you want to do.
<?php
$ids_tofind = array(1,6,3); //for example
$id = implode(",",$ids_tofind);
$link = mysqli_connect('localhost','root','pass','ACS_SHAREPOINT_ADDONS');
// Select table and arguments
$query = "SELECT * FROM Card_File WHERE id IN(". $id.")";
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result)){;?>
<div class="loginForms">
<form target="_blank" action="https://www.website.com" method="post">
<input type="hidden" name="username" id="auth-form-login" value="<?php echo $row['username']; ?>"/>
<input type="hidden" name="password" id="auth-form-pass" value="<?php echo $row['password']; ?>"/>
<input type="hidden" name="redirDocument" value="user"/>
<input type="hidden" name="query" value=""/>
<input type="hidden" name="urlString" value="doc-rc-login;lng-ww-en;tpl-;ver-;"/>
<input type="submit" name="authSubmit" value="AVG Resellers Center" id="auth-form-submit"/>
</form>
</div>
<?php };?>
This will echo out the form for all three users with ID 1, 6 and 3.

Related

PHP - Randomized data displayed in text box when Submit is clicked

Hello I have a database and its data is this please see this image
I need a solution to this problem, the solution is i need the data to be change and not repeating, so when i input a value that is written on the database the displayed value on the textbox will not REPEAT and Change everytime i input the same value.
<form action="" method="POST">
<div class="row col-md-4">
<label>Amount</label>
<input type="text" name="id" class="form-control validate">
<br>
<input type="submit" class="form-control btn-warning" name="search" value="Search Data"></input><br>
//HERE IS WHERE I SUBMIT THE DATA RIGHT NOW IT IS NOT RANDOMIZED WHEN I SUBMIT AGAIN THE SAME VALUE APPEARS
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection, 'qrproject');
if(isset($_POST['search'])){
$id = $_POST['id'];
$query = "SELECT * FROM scratch_cards WHERE amount='$id' ";
$query_run = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($query_run)) {
?>
<form action="" method="POST">
<input type="text" name="code" value="<?php echo $row['code'] ?>" class="form-control validate" id="mapo">
<input type="text" name="pin" value="<?php echo $row['pin'] ?>" class="form-control validate" id="mact">
<input type="text" name="status" value="<?php echo $row['status'] ?>" class="validate form-control" id="soluong">
<input type="date" name="card_expiration" value="<?php echo $row['card_expiration'] ?>" class="validate form-control" id="cardex">
<input type="number" name="card_validity" value="<?php echo $row['card_validity'] ?>" class="validate form-control" id="cardval">
</form>
<?php
}
}
?>
</form>
Maybe as per your comment, you need unique records, so you can use DISTINCT in your query so by giving DISTINCT to any column, you won't get repeated records.
Here in your case:
SELECT DISTINCT id, amount FROM scratch_cards WHERE amount='$id'
Maybe this can help you to get unique records

Filling html forms with mysql data using php coming up null

I am trying to fill a html form with data being received out of my mysql database. However I cannot set the forms to display on-load the variables being extracted from the database. I would like the form on-load to hold the data last entered into the forms which have been added to the database previously.
$query = "SELECT FROM character_tbl WHERE character_player
='".$_SESSION["user"]."' character_tbl";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$name = $row['character_name'];
$race = $row['character_race'];
$class = $row['character_class'];
$alignment = $row['character_alignment'];
$hp = $row['character_hp'];
$str = $row['character_str'];
$dex = $row['character_dex'];
$con = $row['character_con'];
$int = $row['character_int'];
$wis = $row['character_wis'];
$cha = $row['character_cha'];
$ac = $row['character_ac'];
$touch = $row['character_touch'];
$flat = $row['character_flat'];
$fort = $row['character_fort'];
$ref = $row['character_ref'];
$will = $row['character_will'];
}
echo $will;
mysql_close();
?>
<!DOCTYPE html>
<html>
<body>
<div id="nav">
<form action="user.php">
<input type="submit" value="Back">
</form>
</div>
<div id="section">
<form action="update.php" method="POST">
Character Name:<br>
<input type="text" name="name" value="<?php echo $name;?>">
<br>
Race<br>
<input type="text" name="race" value="<?php echo $race;?>">
<br>
Class<br>
<input type="text" name="class" value="<?php echo $class;?>">
<br>
Alignment<br>
<input type="text" name="alignment" value="<?php echo $alignment;?>">
<br>
HP<br>
<input type="text" name="hp" value="<?php echo $hp;?>">
<br>
STR<br>
<input type="number" name="str" value="<?php echo $str;?>">
<br>
DEX<br>
<input type="number" name="dex" value="<?php echo $dex;?>">
<br>
CON<br>
<input type="text" name="con" value="<?php echo $con;?>">
<br>
INT<br>
<input type="text" name="int" value="<?php echo $int;?>">
<br>
WIS<br>
<input type="text" name="wis" value="<?php echo $wis;?>">
<br>
CHA<br>
<input type="text" name="cha" value="<?php echo $cha;?>">
<br>
AC<br>
<input type="text" name="ac" value="<?php echo $ac;?>">
<br>
Touch AC<br>
<input type="text" name="touch" value="<?php echo $touch;?>">
<br>
Flat-Footed AC<br>
<input type="text" name="flat" value="<?php echo $flat;?>">
<br>
Fortitude<br>
<input type="text" name="fort" value="<?php echo $fort;?>">
<br>
Reflex<br>
<input type="text" name="ref" value="<?php echo $ref;?>">
<br>
Will<br>
<input type="text" name="will" value="<?php echo $will;?>">
</br>
<input type="submit" value="Update">
</form>
I think the SQL has error:
SELECT FROM character_tbl WHERE character_player
try:
SELECT * FROM character_tbl WHERE character_player
You have syntax error in your mysql query. You have not place field or columns name or (*) for all columns to extract.
Try like this..
$query = "SELECT * FROM character_tbl WHERE character_player ='".$_SESSION['user']."'";

Fetching URL vars into form and submitting to other page

I have this url: torneioJogo.php?equipaleft=24&equiparight=25&torneioid=8
The following code is in this url...
<form method='GET' action='torneioJogoSub.php?'>
//THESE INPUTS DOWN HERE
<input type="hidden" name="equipa1" value="<?php $_GET['equipaleft'] ?>">
<input type="hidden" name="equipa2" value="<?php $_GET['equiparight'] ?>">
<input type="hidden" name="torneioid" value="<?php $_GET['torneioid'] ?>">
<div id="pontos">
<input type="submit" name="win1" value="<=Vencedor">
<input type="submit" name="emp" value="Empate">
<input type="submit" name="win2" value="Vencedor=>">
<br>
<=Pontos=><br>
//AND THESE INPUTS DOWN HERE
<input type="text" name="pontos1" size="3">
<input type="text" name="pontos2" size="3">
<br>
</div>
</form>
When I submit the form, I need all the data from those inputs in the next page where I have this:
echo "equipa1: " . $_GET['equipa1'];
echo "equipa2: " . $_GET['equipa2'];
echo "torneioid: " . $_GET['torneioid'];
echo "pontos1: " . $_GET['pontos1'];
echo "pontos2: " . $_GET['pontos2'];
What happens is $_GET['pontos2'] and $_GET['pontos1'] work but the values from the hidden inputs (which are being pulled from the url variables), echo nothing. What's happening? Is this a problem with GETs and POSTs or am I missing something else?
You need to echo the values out
<input type="hidden" name="equipa1" value="<?php echo $_GET['equipaleft'] ?>">
<input type="hidden" name="equipa2" value="<?php echo $_GET['equiparight'] ?>">
<input type="hidden" name="torneioid" value="<?php echo $_GET['torneioid'] ?>">
You need to actually output the variables into the form fields
<input type="hidden" name="equipa1" value="<?php echo $_GET['equipaleft'] ?>">
^^^^

Passing form inputs from different pages to submit at final page

I have 4 different pages both with one form each.
I want to gather all the entries on each of the pages and submit once.
Here is code.
Page 1
<form action="page2" method="POST">
<input type="text" name="sex">
<input type="submit" value="Submit">
</form>
Page 2
<form action="page3" method="POST">
<input type="text" name="size">
<input type="hidden" name="sex" value="<?php echo $_POST['sex'] ?>" >
<input type="submit" value="Submit">
</form>
Page 3
<form action="page4" method="POST">
<input type="text" name="colors">
<input type="hidden" name="size" value="<?php echo $_POST['size'] ?>" >
<input type="submit" value="Submit">
</form>
Page 4
<form action="verNote.php" method="POST">
<input type="text" name="likes">
<input type="hidden" name="colors" value="<?php echo $_POST['colors'] ?>" > <input type="submit" value="Submit">
</form>
Then i will like to get all the infos on verNote.php
<?php
echo $_POST['sex'];
echo '<br>';
echo $_POST['size'];
echo '<br>';
echo $_POST['color'];
echo '<br>';
echo $_POST['likes'];
?>
This code above dont seem to post entries from both pages 1 and 2, just for 3 and 4 alone gets submitted.
Will appreciate immediate assistance form anyone who understands my question.
Regards!
You need to load the hidden fields again each time
Page 3
<form action="B.php" method="POST">
<input type="text" name="colors">
<input type="hidden" name="size" value="<?php echo $_POST['size'] ?>" >
<input type="hidden" name="sex" value="<?php echo $_POST['sex'] ?>" >
<input type="submit" value="Submit">
</form>
Page 4
<form action="B.php" method="POST">
<input type="text" name="likes">
<input type="hidden" name="colors" value="<?php echo $_POST['colors'] ?>" >
<input type="hidden" name="sex" value="<?php echo $_POST['sex'] ?>" >
<input type="hidden" name="size" value="<?php echo $_POST['size'] ?>" >
<input type="submit" value="Submit">
</form>
I didn't understand 100% what you're trying to achieve, but have you tried using sessions?
Do this in B.php:
<?php
session_start();
if( isset($_POST['sex']))
$_SESSION['sex'] = $_POST['sex'];
if( isset($_POST['size']))
$_SESSION['size'] = $_POST['size'];
if( isset($_POST['color']))
$_SESSION['color'] = $_POST['color'];
if( isset($_POST['likes']))
$_SESSION['likes'] = $_POST['likes'];
?>
Then you can retrieve the values from any other file, just call session_start(); and use the $_SESSION superglobal.
EDIT
Using sessions, you verNote.php file could be something like this:
<?php
session_start();
echo $_SESSION['sex'];
echo '<br />';
echo $_SESSION['size'];
echo '<br />';
echo $_SESSION['color'];
echo '<br />';
echo $_SESSION['likes'];
echo '<br />';
?>

How to implement Paybox deferred payment?

How do I integrate paybox system to handle deferred payment?
I learned that PBX_DIFF parameter is used to mention no. of days to delay the transaction. Thats exactly what I wanted. But there seems no working code for php with deferred payment for Paybox.
The following code is working fine without mentioning the deferred payment parameter (PBX_DIFF). But when I add that parameter, its not working
<form name="paybox_frm" id="paybox_frm" method="GET" action="<?php echo $payboxUrl;?>">
<input type="hidden" name="PBX_SITE" value="<?php echo $PBX_SITE; ?>">
<input type="hidden" name="PBX_RANG" value="<?php echo $PBX_RANG; ?>">
<input type="hidden" name="PBX_IDENTIFIANT" value="<?php echo $PBX_IDENTIFIANT; ?>">
<input type="hidden" name="PBX_TOTAL" value="<?PHP echo $MONTANT;?>">
<input type="hidden" name="PBX_DEVISE" value="<?php echo $PBX_DEVISE; ?>">
<input type="hidden" name="PBX_CMD" value="<?PHP echo $REFERENCE;?>">
<input type="hidden" name="PBX_PORTEUR" value="<?PHP echo $PORTEUR;?>">
<input type="hidden" name="PBX_RETOUR" value="<?php echo $PBX_RETOUR;?>">
<input type="hidden" name="PBX_HASH" value="<?php echo $PBX_HASH;?>">
<input type="hidden" name="PBX_TIME" value="<?PHP echo $datetime;?>">
<input type="hidden" name="PBX_HMAC" value="<?PHP echo $pbx_hmac;?>">
<!-- Code added for return url-->
<input type="hidden" name="PBX_REFUSE" value="<?PHP echo $PBX_REFUSE;?>" />
<input type="hidden" name="PBX_ANNULE" value="<?PHP echo $PBX_ANNULE;?>" />
<input type="hidden" name="PBX_EFFECTUE" value="<?PHP echo $PBX_EFFECTUE;?>" />
<input type="hidden" name="PBX_LANGUE" value="<?PHP echo $PBX_LANGUE;?>" />
Any help greatly appreciated. Thanks in advance.
<section class="rl-box">
<div class="container padd-xs-0">
<div class="content-section1">
<div class="left-cont col-md-12 col-sm-12"
<div class="container-fluid">
<?php
$PBX_SITE = "1999888";
$PBX_RANG = "32";
$PBX_IDENTIFIANT = "your identifiant id";
$secretKeyTest = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
$PBX_PORTEUR = "your-email";
$PAYBOX_DOMAIN_SERVER = "tpeweb.paybox.com";
$dateTime = date("c");
$PBX_TOTAL = 4000; //$_POST["PBX_TOTAL"]; // Amount
$PBX_DEVISE = 978;
//$PBX_CMD = $_POST["PBX_CMD"]."|".$_POST["user"]."|".$_POST["typed"]."|".$_POST["period"]."|".$_POST["id"]; // order ID no.
$PBX_CMD = 1; // order ID no.
$PBX_RETOUR = "Mt:M;Ref:R;Auto:A;Erreur:E";
$PBX_HASH = "SHA512";
$PBX_TIME = $dateTime;
//$PBX_EFFECTUE = "http://www.leader-underwriting.eu/payment/payment.php";
$msg = "PBX_SITE=$PBX_SITE" .
"&PBX_RANG=$PBX_RANG" .
"&PBX_IDENTIFIANT=$PBX_IDENTIFIANT" .
"&PBX_TOTAL=$PBX_TOTAL" .
"&PBX_DEVISE=$PBX_DEVISE" .
"&PBX_CMD=$PBX_CMD" .
"&PBX_PORTEUR=$PBX_PORTEUR" .
"&PBX_RETOUR=$PBX_RETOUR" .
"&PBX_HASH=$PBX_HASH" .
"&PBX_TIME=$PBX_TIME";
$binKey = pack("H*", $secretKeyTest);
$hmac = strtoupper(hash_hmac('sha512', $msg, $binKey));
$cuu = str_replace(",", "", $ramount);
?>
<form method="POST" name="form_payment" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi">
<input type="hidden" name="PBX_SITE" value="<?php echo $PBX_SITE; ?>">
<input type="hidden" name="PBX_RANG" value="<?php echo $PBX_RANG; ?>">
<input type="hidden" name="PBX_IDENTIFIANT" value="<?php echo $PBX_IDENTIFIANT; ?>">
<input type="hidden" name="PBX_TOTAL" value="<?php echo $PBX_TOTAL; ?>"> <!--dynamic-->
<input type="hidden" name="PBX_DEVISE" value="<?php echo $PBX_DEVISE; ?>">
<input type="hidden" name="PBX_CMD" value="<?php echo $PBX_CMD; ?>"> <!--dynamic-->
<input type="hidden" name="PBX_PORTEUR" value="<?php echo $PBX_PORTEUR ?>">
<input type="hidden" name="PBX_RETOUR" value="<?php echo $PBX_RETOUR; ?>">
<input type="hidden" name="PBX_HASH" value="<?php echo $PBX_HASH; ?>">
<input type="hidden" name="PBX_TIME" value="<?php echo $PBX_TIME; ?>">
<input type="hidden" name="PBX_HMAC" value="<?php echo $hmac; ?>">
<button type="submit" class="btn btn-primary payment">
Payer
</button>
</form>
<center>
</center>
</div>
</div>
</div> <!-- .container-fluid -->
</div>
</div>
</div>
</section>

Categories