fabien fabien - 1 year ago 68
Javascript Question

Php : cant sumbit the good form

Sorry for my spelling

Hi, im trying to make a website showing internet forfeit, so in mySQL database i put all my information then I print it on my web page, the the user click on the forfeit he wants, it brings him to an other page that shows all the forfeit informations... In the while(), I'm making unique form for each forfeit, then on the

The problem here is that the only form sumbitted is the last one created

include_once "DataBase/db.php";

if($internet->num_rows != 0){
while($rows = $internet->fetch_assoc()){
$nom = $rows["nom"];
$id = $rows["id"];
$tech = $rows["technologie"];
$telechargement = $rows["telechargement"];
$televersement = $rows["televersement"];
$utilisation = $rows["utilisation"];
$prix= $rows["prix"];

echo '
<form method="POST" action="Fournisseurs/Videotron.php" id="'.$id.'">

<div class="boxes">
<div class="[ price-option price-option--high ]">
<div class="price-option__detail">
<span class="price-option__cost">'.$nom.'<br>$'.$prix.'</span>

<input type="hidden" name="id" value="'.$id.'"></input>
<input type="hidden" name="nom" value="'.$nom.'"></input>
<input type="hidden" name="tech" value="'.$tech.'"></input>
<input type="hidden" name="telechargement" value="'.$telechargement.'"></input>
<input type="hidden" name="televersement" value="'.$televersement.'"></input>
<input type="hidden" name="utilisation" value="'.$utilisation.'"></input>
<input type="hidden" name="prix" value="'.$prix.'"></input>

<div class="price-option__purchase">
<a href="javascript:document.getElementById('.$id.').submit();"> Submit </a>

You can see what i'm talking about here : http://fournisseursquebec.com/Forfaits.php

just select internet

Thank you!

Answer Source

You are missing the closing </form> tag for every box. Now you have one big form with a lot of repeated fields:

<form method="POST" action="Fournisseurs/Videotron.php" id="'.$id.'">
box 1:
<input type="hidden" name="id" value="'.$id.'"></input>
.... box 2:
<input type="hidden" name="id" value="'.$id.'"></input>

The name attribute of the various input is the one that is sent and should be unique inside every form.

Just add the </form> tag in your while loop and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download