Ich habe ein System, das nur zwei Transaktion, Registration.php und req.php hat. Die beiden Transaktionsdaten werden in der Tabelle new in meiner Datenbank gespeichert. Registration.php ist meine erste Transaktion, dann req.php. Diese PHP-Dateien sind Form, die beide eine Schaltfläche senden, die mit add.php verknüpft ist. Die Felder meiner neuen Tabelle sind in die zwei Formen unterteilt. Der Fluss ist, dass zuerst Registration.php ausgeführt wird dann req.php. Meine Tabelle new hat einen Primärschlüssel namens new_id und sein automatisches Inkrement. Mein Problem ist, dass nach der Ausführung beider Formulare NUR die Daten von Registration.php in der Datenbanktabelle neu gespeichert werden und die req.php leer sind. Was ist das Problem? Ich brauche deine Hilfe.Wie zwei PHP-Formulardateien mit der gleichen ID verbinden und speichern Sie ihre Daten zusammen in der Datenbank:
hier ist der Registration.php Code:
<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js">
</script>
<TITLE>
New Registration Form
</TITLE></head>
<body>
<center>
<br>
<p style="font-weight: bold; font-size: 30">Please Fill Out Your Information Sheet</p><p><?php
echo date('F j, Y, g:i a', time()+25200);
?></p>
<form method="POST" action="add.php">
<!--<input type="text" name="new_fname" class="Form-Control" placeholder="First Name" id="fname" required>-->
<input type="text" name="new_fname" class="Form-Control" placeholder="First Name" id="fname" required>
<input type="text" name="new_mname" class="Form-Control" placeholder="Middle Initial" id="mname" required>
<input type="text" name="new_lname" class="Form-Control" placeholder="Last Name" id="lname" required><br><br>
Select Your gender
<select name="new_gender">
<option value=""></option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
Select Your Status
<select name="new_status">
<option value=""></option>
<option value="New">New</option>
<option value="Old">Old</option>
<option value="Transferee">Transferee</option>
<option value="Shiftee">Shiftee</option>
</select>
Select Your Course
<select name="new_course">
<option value=""></option>
<option value="BSINFOTECH">BSINFOTECH</option>
<option value="BSIS">BSIS</option>
<option value="BSCOMTECH">BSCOMTECH</option>
</select>
<br><br>
<input type="text" name="new_age" class="Form-Control" placeholder="Age" id="age" required><br><br>
<input type="text" name="new_bp" class="Form-Control" placeholder="Birth Place" id="bp" required><br><br>
<input type="text" name="new_add" class="Form-Control" placeholder="Address" id="add" required><br><br>
<input type="text" name="new_nat" class="Form-Control" placeholder="Nationality" id="nat" required><br><br>
<input type="text" name="new_rel" class="Form-Control" placeholder="Religion" id="rel" required><br><br>
<input type="text" name="new_tel" class="Form-Control" placeholder="Tel. No." id="tel" required><br><br>
<input type="text" name="new_cel" class="Form-Control" placeholder="Cel. No." id="cel" required><br><br>
<input type="text" name="new_mail" class="Form-Control" placeholder="E-mail Address" id="mail" required><br><br>
<button onclick="parent.location='req.php'" type="submit" name="next">Next</button>
<button type="submit" class="btn" name="save" value="save">Save</button>
</form>
</body>
</html>
hier ist der req.php Code:
<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js">
</script>
<title>
REQUIRMENTS FORM
</title>
<br>
<p align="center" style="font-size: 50">REQUIRMENTS FORM</p>
</head>
<body>
<center>
<br>
<p align="center" style="font-size: 30">Registrar</p>
<form style="font-size: 20" action="add.php" method='post'>
Form 138
<br>
<select name="form1">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Form 137A
<br>
<select name="form2">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
2 X 2 ID
<br>
<select name="picture">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
NSO Birth Certificate
<br>
<select name="nso">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Good Moral Certificate
<br>
<select name="gmc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<p align="center" style="font-size: 30">Library</p>
Library Card
<br>
<select name="lc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
<br>
<p align="center" style="font-size: 30">Cashier</p>
<p><h4>You should have paid minimum of P2000.00-2500.00</h4></p>
<input type="text" name="cashier" class="Form-Control" width="100px" placeholder="Enter amount" id="cashier" required></input>
<button type="submit" style="font-size: 20" class="btn btn-primary btn-block" name="submit" value="save">SUBMIT</button>
<button type="button" style="font-size: 20" class="btn btn-primary btn-block"><a href="newform.php?id=<?php echo $data->new_id ?>">Process Student Copy</button>
<input type="hidden" value="<?php echo $data->new_id ?>" name="id" >
</form>
</body>
</html>
hier ist der add.php Code:
<?php
mysql_connect("localhost","root");
mysql_select_db("enrollee");
$course=$_POST['new_course'];
$gender=$_POST['new_gender'];
$gender=$_POST['new_gender'];
$status=$_POST['new_status'];
$fname=$_POST['new_fname'];
$mname=$_POST['new_mname'];
$lname=$_POST['new_lname'];
$age=$_POST['new_age'];
$bp=$_POST['new_bp'];
$add=$_POST['new_add'];
$nat=$_POST['new_nat'];
$rel=$_POST['new_rel'];
$tel=$_POST['new_tel'];
$cel=$_POST['new_cel'];
$mail=$_POST['new_mail'];
form1=$_POST['form1'];
$form2=$_POST['form2'];
$picture=$_POST['picture'];
$nso=$_POST['nso'];
$gmc=$_POST['gmc'];
$lc=$_POST['lc'];
$cashier=$_POST['cashier'];
mysql_query("INSERT INTO new(new_id,new_course,new_gender,new_status,new_fname,new_mname,new_lname,new_age,new_bp,new_add,new_nat,new_rel,new_tel,new_cel,new_mail,form1,form2,picture,nso,gmc,lc,cashier))
VALUES(NULL, '$course','$gender', '$status', '$fname','$mname','$lname','$age','$bp','$add','$nat','$rel','$tel','$cel','$mail','$form1','$form2','$picture','$nso','$gmc','$lc','$cashier')");
header("Location: read.php");
?>
Können wir etwas Code bitte sehen, schwer zu helfen, zu debuggen, wenn wir nicht wissen, was passiert. – Sarcoma
müssen Sie uns etwas von Ihrem Code geben, es könnte eine beliebige Anzahl von Problemen sein – Billy
ID sollte für das gesamte Dokument eindeutig sein .. – santosh