FlorianSL February 2016

Get var from a PHP page

I'm having a problem with my PHP. I would like to send data from my page to another page. But it's all in PHP. I need to take an input value and a combobox value. And I don't know how to do it.

Here's my PHP :

<?php 
session_start();

$q = intval($_GET['q']);

$db = mysql_connect('localhost', 'root', 'root'); 
mysql_select_db('Projet',$db);



$sql2 = "select IDControle, NomControle from Controle WHERE IDUser='".$_SESSION['id']."'";
$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql2.'<br>'.mysql_error());

echo'<select id="controleChoix" name="controleChoix">';

while ($data2 = mysql_fetch_array($req2)){
    echo '<option value="'.$data2['IDControle'].'">'.$data2['NomControle'].'</option>';
}

echo '</select>';
echo '<input type="hidden" name="selected_text" id="selected_text" value="" />';



$sql = "select ID, Nom, Prenom from User where Groupe ='".$q."'";
$req = mysql_query($sql) or die('Erreur SQL 2!<br>'.$sql.'<br>'.mysql_error());

echo '<ul class="list-group">';

while ($data = mysql_fetch_array($req)){

    echo '<li class="list-group-item"><strong>Nom</strong>  : '.$data['Nom'].' <br> <strong>Prénom</strong>  : '.$data['Prenom'].'<br>';
    echo '<input type="text" name="note" id="note"/> &nbsp;&nbsp;&nbsp;';
    echo '<a class="label label-success" href="ajouterNote.php?var1='.$data2['IDControle'].'&var2='.$data['ID'].'&var3='.$test.'"><i class="fa fa-fw fa-check"></i></a></li>';

}
echo '</ul>';
echo '<a class="btn btn-primary" href="#">Ajouter toutes les notes</i></a></li>';

?>  

I need to send the input note.value, the select controleChoix.value and the intval q that I've received from another page.

Answers


DurtyFree February 2016

As you already seem to use SESSIONS, you could easily transfer your data from one page to another using these $_SESSION variables.

https://secure.php.net/manual/en/book.session.php

edit: Please keep in mind that this isn't secure at all. The values can easily be changed by the user. Using this you might want to validate the values first, before using.

Post Status

Asked in February 2016
Viewed 2,821 times
Voted 10
Answered 1 times

Search




Leave an answer