Page 1 of 1 |
spankie
VIP Member
Posts: 2958
Location: Belgium
|
Posted: Sun, 5th Apr 2009 02:07 Post subject: php using post form to pass variables to itself? |
|
 |
hi,
i have a very weird problem... I have used this method like a zillion times before, but it looks like i am missing something...
I just want to pass variables via a form using POST to another php script. That php script verifies the data and passes it to itself and show a confirm button.
But for some reason the paramters that get passed to the script itself are not captured using $_POST[''], quite desperate atm...
what is wrong wizards?
Code: | <html>
<body>
<?php
/* DB connect */
$con = mysql_connect("localhost","tralallalala","tralalalalalalala");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tralalalallaallala", $con);
/* Read values */
$pos[1] = $_POST["pos1"];
$pos[2] = $_POST["pos2"];
$pos[3] = $_POST["pos3"];
$pos[4] = $_POST["pos4"];
$pos[5] = $_POST["pos5"];
$pos[6] = $_POST["pos6"];
$pos[7] = $_POST["pos7"];
$pos[8] = $_POST["pos8"];
$pole = $_POST["pole"];
$fast = $_POST["fast"];
$race = $_POST["race_name"];
$send = $_POST["prono_send"];
echo "Prono voor race #".$race."<br>\n\n";
/* Pre confirming */
if ($send == "Prono verzenden!"){
/* Error checker */
$errors = 0;
/* Check zelfde drivers */
for($i = 1; $i <= 8; $i++){
for($j = $i+1; $j <= 8; $j++){
if ($pos[$i] == $pos[$j]){
echo "Positie met zelfde naam: positie ".$i." en positie ".$j."<br>\n";
}
}
}
/* Check 0 */
for($i = 1; $i <= 8; $i++){
if ($pos[$i] == 0){
echo "Positie ".$i." is niet ingevuld!<br>\n";
$errors++;
}
}
if ($pole == 0){
echo "Pole position is niet ingevuld!<br>\n>";
$errors++;
}
if ($fast == 0){
echo "Fastest lap is niet ingevuld!<br>\n>";
$errors++;
}
/* Print 2 verify */
if ($errors == 0){
echo "<form action=\"prono_fill_submit.php\" method=\"post\">\n";
echo "<table>\n";
/**/
for ($i = 1; $i <= 8; $i++){
echo "<tr><td>Positie".$i."</td><td>";
$sql = "SELECT * FROM prono_drivers_09 WHERE nr = '$pos[$i]'";
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo $row['nr']." ".$row['first_name']." ".$row['last_name'];
echo "</td></tr>\n";
}
/**/
echo "<tr><td>Pole Position</td><td>";
$sql = "SELECT * FROM prono_drivers_09 WHERE nr = '$pole'";
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo $row['nr']." ".$row['first_name']." ".$row['last_name'];
echo "</td></tr>\n";
/**/
echo "<tr><td>Fastest Lap</td><td>";
$sql = "SELECT * FROM prono_drivers_09 WHERE nr = '$fast'";
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo $row['nr']." ".$row['first_name']." ".$row['last_name'];
echo "</td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos1\" value\"".$pos[1]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos2\" value\"".$pos[2]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos3\" value\"".$pos[3]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos4\" value\"".$pos[4]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos5\" value\"".$pos[5]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos6\" value\"".$pos[6]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos7\" value\"".$pos[7]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pos8\" value\"".$pos[8]."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"pole\" value\"".$pole."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"fast\" value\"".$fast."\"></td><td></td></tr>\n";
echo "<tr><td><input type=\"hidden\" name=\"race_name\" value\"".$race."\"></td><td></td></tr>\n";
/* Confirm buttons etc */
echo "<tr><td>Login</td><td><input type=\"text\" name=\"user\"></td></tr>\n";
echo "<tr><td>Pass</td><td><input type=\"password\" name=\"pass\"></td></tr>\n";
echo "<tr><td><input type=\"submit\" name=\"prono_send\" value=\"Prono definitief verzenden!\"></td><td><input type=\"reset\" value=\"User en pass wissen\"</td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "<form action=\"prono_fill.php\" method=\"post\">\n";
echo "<input type=\"submit\" value=\"ik zien biele, helemaal erbeginnen\">\n";
echo "</form>\n";
}
}
if ($send == "Prono definitief verzenden!"){
$user = $_POST["user"];
$pass = $_POST["pass"];
$p1 = "race_".$race."_1";
$p2 = "race_".$race."_2";
$p3 = "race_".$race."_3";
$p4 = "race_".$race."_4";
$p5 = "race_".$race."_5";
$p6 = "race_".$race."_6";
$p7 = "race_".$race."_7";
$p8 = "race_".$race."_8";
$pp = "race_".$race."_p";
$pf = "race_".$race."_f";
$rd = "race_".$race."_date";
$sql = "SELECT pass, $rd FROM prono_users_09 WHERE login = '$user'";
echo $sql;
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if ($row['pass'] == $pass){
if (!$row[$rd]){
echo "Prono is bevestigd en zit in de DB @ pc tijd".time();
}
else {
echo "Snoodaard! Je hebt al keer ingevuld @ ".$row[$rd];
}
}
else {
echo "pass mis, pipo, moest zijn: ".$row['pass']." en je vulde in: ".$pass;
}
}
/* if prono_confirm_send dan naar db en verify en zo */
/* Add login/pass verifier die terugkeert in de confirm dinges als de login bestaat en de pass mis is */
?>
</body>
</html> |
|
|
Back to top |
|
 |
|
Posted: Sun, 5th Apr 2009 02:11 Post subject: |
|
 |
Sorry but is this your final code? No countermeasures against sql injections? I could be wrong as I am not a professionals @ php+sql but it seems as if somebody could add some bad bad mysql directives that could fuck up your db...
And hidden is NOT a good way to hide data from the user Why don't you write the sensitive data into a session variable?
And again, I'm not a pro 
|
|
Back to top |
|
 |
lhzr
Posts: 3902
Location: RO
|
Posted: Sun, 5th Apr 2009 02:19 Post subject: |
|
 |
your hidden table contains value\"".$pos[2]
try replacing it with value=\"".$pos[2]
|
|
Back to top |
|
 |
|
Posted: Sun, 5th Apr 2009 02:21 Post subject: |
|
 |
loool right 
|
|
Back to top |
|
 |
lhzr
Posts: 3902
Location: RO
|
|
Back to top |
|
 |
spankie
VIP Member
Posts: 2958
Location: Belgium
|
|
Back to top |
|
 |
|
Posted: Sun, 5th Apr 2009 03:07 Post subject: |
|
 |
Well than it's ok. Because they could easily chead by change the hidden confirmation data on the fly.
|
|
Back to top |
|
 |
lhzr
Posts: 3902
Location: RO
|
Posted: Sun, 5th Apr 2009 03:21 Post subject: |
|
 |
how would they go about doing that?
|
|
Back to top |
|
 |
|
|
Back to top |
|
 |
lhzr
Posts: 3902
Location: RO
|
|
Back to top |
|
 |
|
Posted: Sun, 5th Apr 2009 22:26 Post subject: |
|
 |
While the confirmation page shows up, you could easily open up the sourcecoude via opera and change the values inside the hidden inputs 
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |