Hej.
Jeg prøver når jeg indsætter data fra en form til en tabel at blive linket til den næste side hvor den skal bruges til at sortere data fra en anden tabel når de hentes frem. Første fil er herunder hvor data indsættes i tabellen ddsmem og herfra er det memID skal hentes frem fra kolonnen ID. Dette skal sendes videre til næste side.
- <?php require_once('../Connections/localhost.php'); ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
-
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
-
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
-
- $editFormAction = $_SERVER['PHP_SELF'];
- if (isset($_SERVER['QUERY_STRING'])) {
- $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
- }
-
- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
- $insertSQL = sprintf("INSERT INTO ddsmem (Medlemsnummer, Navn, Adresse, Stednavn, Postnummer, Bynavn, skyttenummer, betalt, phone, membercard, Riffel, Pistol, Grov, SKV, email, bestyrelse, indmelddato) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
- GetSQLValueString($_POST['Medlemsnummer'], "text"),
- GetSQLValueString($_POST['Navn'], "text"),
- GetSQLValueString($_POST['Adresse'], "text"),
- GetSQLValueString($_POST['Stednavn'], "text"),
- GetSQLValueString($_POST['Postnummer'], "text"),
- GetSQLValueString($_POST['By'], "text"),
- GetSQLValueString($_POST['Medlemsnummer'], "text"),
- GetSQLValueString($_POST['Betalt'], "text"),
- GetSQLValueString($_POST['Telefon'], "text"),
- GetSQLValueString($_POST['Membercard'], "text"),
- GetSQLValueString($_POST['Riffel'], "text"),
- GetSQLValueString($_POST['Pistol'], "text"),
- GetSQLValueString($_POST['Grov'], "text"),
- GetSQLValueString($_POST['SKV'], "text"),
- GetSQLValueString($_POST['Email'], "text"),
- GetSQLValueString($_POST['bestyrelse'], "text"),
- GetSQLValueString($_POST['indmeldtdato'], "date"));
-
- mysql_select_db($database_localhost, $localhost);
- $Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
-
- $insertGoTo = "ddsindmeldtbetalt.php";
- if (isset($_SERVER['QUERY_STRING'])) {
- $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
- $insertGoTo .= $_SERVER['QUERY_STRING'];
- }
- header(sprintf("Location: %s", $insertGoTo));
- }
-
- $colname_oplysninger = "-1";
- if (isset($_GET['ID'])) {
- $colname_oplysninger = $_GET['ID'];
- }
- mysql_select_db($database_localhost, $localhost);
- $query_oplysninger = sprintf("SELECT * FROM ddsprove WHERE ID = %s", GetSQLValueString($colname_oplysninger, "int"));
- $oplysninger = mysql_query($query_oplysninger, $localhost) or die(mysql_error());
- $row_oplysninger = mysql_fetch_assoc($oplysninger);
- $colname_oplysninger = "-1";
- if (isset($_GET['recordID'])) {
- $colname_oplysninger = $_GET['recordID'];
- }
- mysql_select_db($database_localhost, $localhost);
- $query_oplysninger = sprintf("SELECT * FROM ddsprove WHERE ID = %s", GetSQLValueString($colname_oplysninger, "int"));
- $oplysninger = mysql_query($query_oplysninger, $localhost) or die(mysql_error());
- $row_oplysninger = mysql_fetch_assoc($oplysninger);
- $totalRows_oplysninger = mysql_num_rows($oplysninger);$colname_oplysninger = "-1";
- if (isset($_GET['recordID'])) {
- $colname_oplysninger = $_GET['recordID'];
- }
- mysql_select_db($database_localhost, $localhost);
- $query_oplysninger = sprintf("SELECT * FROM ddsprove WHERE ID = %s", GetSQLValueString($colname_oplysninger, "int"));
- $oplysninger = mysql_query($query_oplysninger, $localhost) or die(mysql_error());
- $row_oplysninger = mysql_fetch_assoc($oplysninger);
- $totalRows_oplysninger = mysql_num_rows($oplysninger);
-
- mysql_select_db($database_localhost, $localhost);
- $query_valg = "SELECT * FROM ddsvalg";
- $valg = mysql_query($query_valg, $localhost) or die(mysql_error());
- $row_valg = mysql_fetch_assoc($valg);
- $totalRows_valg = mysql_num_rows($valg);
-
- mysql_select_db($database_localhost, $localhost);
- $query_aar = "SELECT * FROM ddsaar";
- $aar = mysql_query($query_aar, $localhost) or die(mysql_error());
- $row_aar = mysql_fetch_assoc($aar);
- $totalRows_aar = mysql_num_rows($aar);
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>DDS-Slagelse</title>
- </head>
-
- <body>
- <p>Bekræftelse oplysningerne for indmeldelse:</p>
- <p> </p>
- <p>Forslået medlemsnummer: <?php echo substr(($row_oplysninger['aar']),-2); ?><?php echo $row_oplysninger['maaned']; ?><?php echo $row_oplysninger['dag']; ?>0001</p>
- <p> </p>
- <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
- <p>
- <label for="Navn">Navn</label>
- <input name="Navn" type="text" id="Navn" value="<?php echo $row_oplysninger['Navn']; ?>" />
- </p>
- <p>
- <label for="Medlemsnummer">Medlemsnummer</label>
- <input name="Medlemsnummer" type="text" id="Medlemsnummer" value="<?php echo substr(($row_oplysninger['aar']),-2); ?><?php echo $row_oplysninger['maaned']; ?><?php echo $row_oplysninger['dag']; ?>0001" />
- </p>
- <p>
- <label for="Adresse">Adresse</label>
- <input name="Adresse" type="text" id="Adresse" value="<?php echo $row_oplysninger['Adresse']; ?>" />
- <label for="Stednavn">Stednavn</label>
- <input name="Stednavn" type="text" id="Stednavn" value="<?php echo $row_oplysninger['Stednavn']; ?>" />
- </p>
- <p>
- <label for="Postnummer">Postnummer</label>
- <input name="Postnummer" type="text" id="Postnummer" value="<?php echo $row_oplysninger['Postnummer']; ?>" />
- <label for="By">By</label>
- <input name="By" type="text" id="By" value="<?php echo $row_oplysninger['By']; ?>" />
- </p>
- <p>
- <label for="Email">E-mail</label>
- <input name="Email" type="text" id="Email" value="<?php echo $row_oplysninger['Email']; ?>" size="25" />
- <label for="Telefon">Telefon</label>
- <input name="Telefon" type="text" id="Telefon" value="<?php echo $row_oplysninger['Telefon']; ?>" />
- </p>
- <p>
- <label for="Henvisning">Henvisning</label>
- <input name="Henvisning" type="text" id="Henvisning" value="<?php echo $row_oplysninger['Henvisning']; ?>" />
- </p>
- <p>
- <label for="Betalt">Betalt år</label>
- <select name="Betalt" id="Betalt">
- <?php
- do {
- ?>
- <option value="<?php echo $row_aar['Aar']?>"><?php echo $row_aar['Aar']?></option>
- <?php
- } while ($row_aar = mysql_fetch_assoc($aar));
- $rows = mysql_num_rows($aar);
- if($rows > 0) {
- mysql_data_seek($aar, 0);
- $row_aar = mysql_fetch_assoc($aar);
- }
- ?>
- </select>
- </p>
- <p>
- <label for="Pistol">Pistol</label>
- <select name="Pistol" id="Pistol">
- <?php
- do {
- ?>
- <option value="<?php echo $row_valg['valg']?>"<?php if (!(strcmp($row_valg['valg'], "Nej"))) {echo "selected=\"selected\"";} ?>><?php echo $row_valg['valg']?></option>
- <?php
- } while ($row_valg = mysql_fetch_assoc($valg));
- $rows = mysql_num_rows($valg);
- if($rows > 0) {
- mysql_data_seek($valg, 0);
- $row_valg = mysql_fetch_assoc($valg);
- }
- ?>
- </select>
- <label for="Riffel">Riffel</label>
- <select name="Riffel" id="Riffel">
- <?php
- do {
- ?>
- <option value="<?php echo $row_valg['valg']?>"<?php if (!(strcmp($row_valg['valg'], "Ja"))) {echo "selected=\"selected\"";} ?>><?php echo $row_valg['valg']?></option>
- <?php
- } while ($row_valg = mysql_fetch_assoc($valg));
- $rows = mysql_num_rows($valg);
- if($rows > 0) {
- mysql_data_seek($valg, 0);
- $row_valg = mysql_fetch_assoc($valg);
- }
- ?>
- </select>
- <label for="Grov">Grov</label>
- <select name="Grov" id="Grov">
- <?php
- do {
- ?>
- <option value="<?php echo $row_valg['valg']?>"<?php if (!(strcmp($row_valg['valg'], "Nej"))) {echo "selected=\"selected\"";} ?>><?php echo $row_valg['valg']?></option>
- <?php
- } while ($row_valg = mysql_fetch_assoc($valg));
- $rows = mysql_num_rows($valg);
- if($rows > 0) {
- mysql_data_seek($valg, 0);
- $row_valg = mysql_fetch_assoc($valg);
- }
- ?>
- </select>
- </p>
- <p>Indmeld
- <input type="submit" name="Submit" id="Submit" value="Submit" />
- </p>
- <p> </p>
- <p>
- <input name="indmeldtdato" type="hidden" id="indmeldtdato" value="<?php echo date("Y-m-d h:m:s"); ?>" />
- <input name="bestyrelse" type="hidden" id="bestyrelse" value="Nej" />
- <input name="SKV" type="hidden" id="SKV" value="0" />
- <input name="Instruktør" type="hidden" id="Instruktør" value="Nej" />
- <input name="Membercard" type="hidden" id="Membercard" value="Nej" />
- </p>
- <input type="hidden" name="MM_insert" value="form1" />
- </form>
- <p> </p>
- </body>
- </html>
- <?php
- mysql_free_result($oplysninger);
-
- mysql_free_result($valg);
-
- mysql_free_result($aar);
- ?>
Det skulle gerne når der bliver indsat linke med følgende:
ddsindmeldtbetalt.php?recordID=<?php echo $row_Recordset2['memID']; ?>
Den fil det bliver sendt over til ser sådan ud:
- <?php require_once('../Connections/localhost.php'); ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
-
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
-
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
-
- $colname_Recordset1 = "-1";
- if (isset($_SESSION['RecordID'])) {
- $colname_Recordset1 = $_SESSION['RecordID'];
- }
- mysql_select_db($database_localhost, $localhost);
- $query_Recordset1 = sprintf("SELECT * FROM ddsmem WHERE ID = %s", GetSQLValueString($colname_Recordset1, "int"));
- $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
- $row_Recordset1 = mysql_fetch_assoc($Recordset1);
- $colname_Recordset1 = "-1";
- if (isset($_GET['recordID'])) {
- $colname_Recordset1 = $_GET['recordID'];
- }
- mysql_select_db($database_localhost, $localhost);
- $query_Recordset1 = sprintf("SELECT * FROM ddsmem WHERE ID = %s", GetSQLValueString($colname_Recordset1, "int"));
- $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
- $row_Recordset1 = mysql_fetch_assoc($Recordset1);
- $totalRows_Recordset1 = mysql_num_rows($Recordset1);
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>DDS-Slagelse</title>
- </head>
-
- <body>
- <p>
- <label for="Navn">Navn</label>
- <input name="Navn2" type="text" id="Navn" value="<?php echo $row_Recordset1['Navn']; ?>" />
- </p>
- <p> </p>
- <table width="600" border="1">
- <tr>
- <td width="300"><form id="form1" name="form1" method="post" action="">
- <p>Hvis indmeldelsen er betalt kontant tryk her.</p>
- <p>
- <input name="Navn" type="hidden" id="Navn" value="<?php echo $row_Recordset1['Navn']; ?>" />
- <input name="plus" type="hidden" id="plus" value="Der" />
- <input name="Konto" type="hidden" id="Konto" value="Er" />
- <input name="Ref" type="hidden" id="Ref" value="Betalt" />
- </p>
- <p>Submit
- <input type="submit" name="Submit2" id="Submit2" value="Submit" />
- </p>
- </form></td>
- <td width="300"><form id="form2" name="form2" method="post" action="">
- <p>Hvis der skal sendes girokort tryk her </p>
- <p>
- <input name="Navn" type="hidden" id="Navn" value="<?php echo $row_Recordset1['Navn']; ?>" />
- <input name="Plus" type="hidden" id="Plus" value="Endnu" />
- <input name="Konto" type="hidden" id="Konto" value="Ikke" />
- <input name="Ref" type="hidden" id="Ref" value="Afsendt" />
- </p>
- <p>Submit
- <input type="submit" name="Submit" id="Submit" value="Submit" />
- </p>
- </form></td>
- </tr>
- </table>
- </body>
- </html>
- <?php
- mysql_free_result($Recordset1);
- ?>
Jeg håber der er nogen der kan og vil hjælpe da jeg har prøvet over 71 løsninger efter at have læst mange artikler på nettet om dette uden held.
På forhånd tak.
//Jess
Indlæg senest redigeret d. 27.08.2014 09:03 af Bruger #20981